You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by "Gary W. Smith" <ga...@primeexalia.com> on 2007/01/20 10:56:02 UTC

SA/Perl Question

Hello, 

I'm working on a perl script that will check some emails.  I had a
question though (based on an earlier question).  If SA is on a different
box how do I tell the perl code to use a different host and port?

Given something like the code below how do I specific a non-default
backend?

#!/usr/bin/perl 

use Mail::SpamAssassin;

my $spamtest = Mail::SpamAssassin->new( { username => 'filter'} );
my $mail = $spamtest->parse(<STDIN>);
my $status = $spamtest->check($mail);

if ($status->is_spam()) {
    print $status->rewrite_mail();
}
$status->finish();
$mail->finish();

exit 0;

Re: SA/Perl Question

Posted by "Daryl C. W. O'Shea" <sp...@dostech.ca>.
Gary W. Smith wrote:

> Mail::SpamAssassin:Client seems to work but is alpha.  Any ideas on the 
> status of this?

I've been using it for a long time with no problems at all.  The 
check_spamd Nagios plugin (available in contrib/ in svn) uses it too.

Daryl

RE: SA/Perl Question

Posted by "Gary W. Smith" <ga...@primeexalia.com>.
Never mind.  I just realized that this module does the full SA
execution.  

 

Mail::SpamAssassin:Client seems to work but is alpha.  Any ideas on the
status of this?

 

Gary Wayne Smith

 

________________________________

From: Gary W. Smith [mailto:gary@primeexalia.com] 
Sent: Saturday, January 20, 2007 1:56 AM
To: users@spamassassin.apache.org
Subject: SA/Perl Question

 

Hello, 

I'm working on a perl script that will check some emails.  I had a
question though (based on an earlier question).  If SA is on a different
box how do I tell the perl code to use a different host and port?

Given something like the code below how do I specific a non-default
backend?

#!/usr/bin/perl 

use Mail::SpamAssassin;

my $spamtest = Mail::SpamAssassin->new( { username => 'filter'} );

my $mail = $spamtest->parse(<STDIN>);

my $status = $spamtest->check($mail);

if ($status->is_spam()) {

    print $status->rewrite_mail();

}

$status->finish();

$mail->finish();

exit 0;


Re: SA/Perl Question

Posted by Matt Kettler <mk...@verizon.net>.
Gary W. Smith wrote:
>
> Hello,
>
> I’m working on a perl script that will check some emails.  I had a
> question though (based on an earlier question).  If SA is on a
> different box how do I tell the perl code to use a different host and
> port?
>
Erm, if you're using Mail::SpamAssassin, you aren't using spamd, you're
loading SA into your process directly.

If you want to make use of spamd, whether local or remote, you'll have
to connect using sockets and speak to it using the spamd protocol:

http://svn.apache.org/repos/asf/spamassassin/branches/3.1/spamd/PROTOCOL

> Given something like the code below how do I specific a non-default
> backend?
>
That code doesn't use *any* backend.
>
> #!/usr/bin/perl
>
> use Mail::SpamAssassin;
>
> my $spamtest = Mail::SpamAssassin->new( { username => 'filter'} );
>
> my $mail = $spamtest->parse(<STDIN>);
>
> my $status = $spamtest->check($mail);
>
> if ($status->is_spam()) {
>
>     print $status->rewrite_mail();
>
> }
>
> $status->finish();
>
> $mail->finish();
>
> exit 0;
>