Francesc Guim Bernat wrote:
> 
> Hi,
> 
>         I want that spamd don't scan emails send to some address, for example
> [EMAIL PROTECTED] I supose that I've to added in my
> conf spamassassin file (/etc/mail/spamassassin/local.cf) the next line:
> 
>         whitelist_to [EMAIL PROTECTED]
> 
>         but I've seen an email about spamassassing that says that this option
> don't work well and it recommends to use the tag
> all_spam_to
> 
>         Some can say me something about whitelist_to  and all_spam_to ?
> 
> Thanks,
> 
> Francesc
> 

There's a few problems with whitelist_to and all_spam_to in a production
environment:

1) Doesn't work as expected if a message is BCC'd (result: angry email
from whitelisted customer asking why they're still getting filtered).

2) If multiple addresses are listed on the To: or CC: lines, with a
combination of whitelisted and non-whitelisted lines, the message is not
marked as spam for any of the recipients. (Result: angry email from
non-whitelisted customer asking why they're still getting spam).

Aside from that, you're wasting time scanning a message even though
you're going to ignore the results.

My solution was the following (global) procmail recipe:

:0fw
# skip passing to spamc/spamd if user is on
# exempt list, or if message is really big.
# all_spam_to has problems, and why burden
# the server w/large messages if we can
# catch them here!
* < 500000
* ! ? /usr/local/bin/nospam.pl $LOGNAME
|/usr/bin/spamc -s 100000 -d my.sa.server -p 783


I guess the -s option is redundant. I left it in there when I added the
conditionals to the recipe. The idea is to only process messages that
are under 500000 bytes, and to skip processing if the username is listed
in /etc/spamassassin/exempt. The exit codes are set up the way they are
so that the default is to process the message, even if the script errors
somehow (locked file, etc). 

There are a couple of drawbacks to this method. There's probably more
efficient ways to handle the exemption list than running a little perl
program for every email. Probably not real bad given the small size of
my exemption list, though (could use dbm or something for a large list).
Also, this method will not allow you to have a filtered and a
non-filtered email address land in the same mailbox, since it's matching
the $LOGNAME variable from procmail. It has held up fine so far, on a
20K+ messages/day system.

Here's the nospam.pl script:

#!/usr/bin/perl
#
# nospam.pl -- accept username as option,
#              check a list of names, see if
#              user wants spam scanning or not
#              0 = skip scanning
#              nonzero = scan (fail "safe" so that
#                        majority of users are scanned)

$userfile="/etc/spamassassin/exempt";
$found="false";
$user=$ARGV[0];

print "$user\n";

open USERS,$userfile or die "unable to open $userfile $!\n";
while (<USERS>) {
        next if ( /^#/ );
        if ( /^$user$/ ) {
                $found="true";
                last;
        };
};

close USERS;

if ( $found eq "true" ){
        exit 0;
};
exit 1;


_________________________________________________________
                         
Rich Puhek               
ETN Systems Inc.         
2125 1st Ave East        
Hibbing MN 55746         
                         
tel:   218.262.1130  
email: [EMAIL PROTECTED] 
_________________________________________________________


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to