[Mimedefang] differing spamassassin configs

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Fri Jan 23 08:37:04 EST 2015

Hash: SHA1

On Thu, 22 Jan 2015, John Nemeth wrote:

>     I've started looking at scanning outbound mail for spam.  This
> is to prevent being added to RBLs.  As part of this, I would like
> to be able to call spamassassin with different settings.  All
> outbound mail is either coming from the same system or authenticated
> users, so when scanning outbound mail I don't want any RBLs being
> consulted.  However, I still want RBLs to be consulted for inbound
> mail.  I've looked at mimedefang.pl and don't see any easy way to
> do this.  The only obvious thing is to set $SASpamTester to undef
> before each call to spamassassin.  I'm wondering if a destructor
> function should be called or if this would result in a memory leak.
> Does anybody have any other suggestions?

Checkout the top of the mimedefang-filter

# The next lines force SpamAssassin modules to be loaded and rules
# to be compiled immediately.  This may improve performance on busy
# mail servers.  Comment the lines out if you don't like them.
if ($Features{"SpamAssassin"}) {
     spam_assassin_init()->compile_now(1) if defined(spam_assassin_init());

     # If you want to use auto-whitelisting:
#   if (defined($SASpamTester)) {
#       use Mail::SpamAssassin::DBBasedAddrList;
#       my $awl = Mail::SpamAssassin::DBBasedAddrList->new();
#       $SASpamTester->set_persistent_address_list_factory($awl) if defined($awl);
#   }

Do this once for one config, save the $SASpamTester in yet another global 
var, e.g. my_SA_inbound; undef $SASpamTester; do this for the second 
config and save $SASpamTester into, say, my_SA_outbound

Now, before you scan, assign either my_SA_* to $SASpamTester.

However, if you have a large ruleset, you load it twice into memory. Also 
look at $SALocalTestsOnly .

- -- 
Steffen Kaiser
Version: GnuPG v1


More information about the MIMEDefang mailing list