Antwort: Re: [Exim] Spamassassin Survey

Pàgina inicial
Delete this message
Reply to this message
Autor: Wolfgang.Fuertbauer
Data:  
A: Greg Ward
CC: Exim Users (E-mail), exim-users-admin, Paul Walsh
Assumpte: Antwort: Re: [Exim] Spamassassin Survey
On 10.04.2002 16:09:40 exim-users-admin wrote:
>On 10 April 2002, Mike Richardson said:
>> I'm relatively new to SA but what I'd like to be able to do is to
>> handle differently scored SA messages differently. e.g If a message
>> scores < 5 then its not spam, if it scores >5 then its spam but if
>> < 10 then still deliver it (with the appropriate X headers). If > 10
>> then don't deliver (filter to another file), and if > 20 then /dev/null
>> it.
>[...]
>> Anyone know of software, or a methodology, which can do the above
>> more sensibly?
>
>Write your own script. I have a Python script that takes care of
>routing spam accordingly; it sits between Exim and SpamAssassin, and
>does the following:
>
>* pipes the message to spamc, and reads the marked-up message
>(ie. with X-Spam-* headers added) back
>
>* interprets the X-Spam-* headers to see if the message is spam
>or not. If so, save it to /var/mail/spam (a Maildir, so it's
>easy to write to). If not, pipe it to exim to resend to the
>original intended recipient(s).
>
>It would be fairly easy to extend this to a three-way decision instead
>of two-way, and to change the logic slightly.
>
>The main disadvantage of this is the overhead of spawning a Python
>interpreter for every message, in addition to the spamc/spamd overhead
>you would incur anyways (which isn't nearly as bad as starting the
>spamassassin script, which starts up a Perl interpreter *and* compiles
>all the SA rules). My gut instinct is that Python is about as expensive
>to spawn as Perl, but my script is fairly small and doesn't import too
>much stuff.
>
>The other disadvantage is that every legitimate message requires an
>additional invocation of Exim and a second message ID. I suspect this
>is universal to external mail-filtering schemes, though.
>
>Oh yeah: it'll all be online at satools.sourceforge.net before the end
>of the week.
>
>Greg


here is an working (quick and dirty) perl-script:

#!/usr/bin/perl
#
# spamcwrapper: gets mail from STDIN, writes it to spamc
#               if spam:
#                       write to $spambox
#                       return nothing
#               if not spam:
#                       return spam-checked mail
#
$spambox = '/var/spool/spam';
# I want all (and I want it now)
undef $/;
$| = 1;
$inmail = <STDIN>;
# send the mail to spamc
$spamcmail = `echo "$inmail" | spamc -u exim -s 5000000`;
# print $spamcmail if not ($spamcmail =~ /.Spam-Flag:\sYE./);
if (!$spamcmail =~ /.Spam-Flag:\sYE./)
        {
         print $spamcmail;
        }
else
        {
         open(SPAMBOX, ">>$spambox")
                or die "Can't open spambox $spambox: $!";
         print SPAMBOX
                "\nSPAMCWRAPPER ", '*' x 80, "\n", $spamcmail;
         close SPAMBOX;
        }
exit 0;