You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by bacon <ba...@aerodyne.com> on 2012/04/20 19:32:46 UTC

calling Mail::SpamAssassin->new() within my perl script

I'm working on a project where I'm trying to use spamassassin to 
recognize and tag a set of incoming mail messages.  I'm using SA 3.3.1 
at the moment with perl 5.10.1 on a Red Hat 6.2 system.

I've written a set of rules which work with my corpus of messages, but 
I'm having trouble calling SpamAssassin from within my perl script so 
that it behaves in the same manner as when I call it from the command 
line.  I've placed my special rules in the directory /etc/mail/journals 
which is a copy of /etc/mail/spamassassin directory with a copy of 
10_default_prefs.cf in addition.  From the command line I use the 
following command

   spamassassin -C /etc/mail/journals -t -L < message

but it also works with

   spamassassin -C /etc/mail/journals 
--siteconfigpath=/etc/mail/journals -t -L < message

This method uses my set of rules, but doesn't use the built in rules.  
What I want to do is strip SpamAssassin down to its bare minimum for 
this task.

My question is what set of arguments should I use in my to call 
Mail::SpamAssassin->new() to achieve the same results.  I've tried 
various combinations of rules_filename and site_rules_filename, but then 
my rules never seem to match the appropriate messages.  Oddly, it works 
every now and then.  I'm sure that I'm missing something really obvious. 
Any suggestions about the appropriate arguments to use?


         my $sa_args = {
                 local_tests_only    => 1,
                 dont_copy_prefs     => 1,
                 site_rules_filename => '/etc/mail/journals',
                 userstate_dir       => '/var/lib',
                 userprefs_filename  => '/etc/mail/journals/local.cf',
                 user_dir            => '/var/spool/MD-Quarantine',
         };

         $SAToCTester = Mail::SpamAssassin->new( $sa_args );

Thanks,

Fred Bacon