On Sun, 30 May 2004, Graham Trott wrote:
I was hoping to avoid procmail as the syntax is so impenetrable. But I don't intend to go anywhere near the mailbox, merely attach a filter to KMail. My server is already catching a lot of spam, but even with 90% accuracy that still lets through ten or more a day so something more drastic is needed. I know bogofilter and spamassassin can be set up to take a stream from KMail and return it back again with suitable modifications to indicate spam or not. I'd like to do something similar but using different criteria based on a list of approved sender addresses.
-- GT
Spamassassin writes to standard out, so probably can be used in this way, docs are sparce on this point however.
You did say "as the mail arrives". So as soon as the mail comes into your system you need to process it, as it get moved into local mailboxes.
This is exactly what a local mail delivery agent does. I only mention Procmail as it is the default LMDA on my RedHat 9.0 system. I expect that you could use any LMDA to do similar things.
I would weed out all good e-mails and send them to one mail box and allow all other mail to fall through to the default mail-box, say IN-spam. Mail would thus be marked by being in a different box.
If you wanted to use the same box for both good and suspect mail you could pipe all suspect mail through a script to mark mail and send it to "in-box" or whatever, Procmail uses an action line:
| mark >> in-box
where mark is a program on the Procmail path, (which you can set). As mark is taking input on standard in and printing on standard out, the program can be very simple:
#! /bin/bash sed -e -s/Subject:/"Subject: <--Spam-->"/
This will change the "Subject line" to include both the <--Spam--> marker and the original subject line. The script terminates on EOF, no test required.
I hope that this helps a little, and that you can adapt this to your own needs.
Leon Stedman.