Nuno,

> sub sa_learn {
>   my($msginfo) = @_;
>   # reconstruct message from msginfo to temp file
>   my $mail = reconstruct_mail($msginfo);
>   open SA, "| sa-learn --no-sync --ham --single";
>          print SA $mail;
>   close SA;
> }
>
> How can i reconstruct the message text from $msginfo object?

Read from it and feed it to stdin of a spawned sa-learn process.
Use sub run_command_consumer to properly spawn a subprocess.
 
A code sample from sub mail_via_smtp_single:

        my($msg) = $msginfo->mail_text;
          # a file handle or a MIME::Entity object

        if (!defined($msg)) {
          # empty mail
        } elsif ($msg->isa('MIME::Entity')) {
          $msg->print_body($smtp_handle);
        } else {
          my($nbytes,$buff);
          while (($nbytes=$msg->read($buff,32768)) > 0)
            { $smtp_handle->datasend($buff) }
          defined $nbytes or die "Error reading: $!";
        }

Depending on a source of a quarantine, a $msginfo->mail_text
is either a normal file handle, or a virtual handle to
an SQL-reading method, or it could also be a MIME::Entity object
(when releasing is requested to wrap an original mail as an attachment).

It may be more straightforward to call SpamAssassin learning
module directly, instead of spawning a sa-learn process.

  Mark

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to