Spamfiltering using Spamassassin and sieve
One of the great advantages of IMAP is, that the server can do all of the sorting and filtering instead of the client. One of the greatest disadvantages of IMAP is, that the server can do all of the sorting and filtering instead of the client. (Yes, that was a copy & paste job).
In practice this means, that while it's great to use sieve to let the server sort all incoming mail into (IMAP-)folders (i.e. for mailing-lists) it also means, that it's (currently!) still pretty tedious to maintain these settings. And nowadays one can plain forget about trying to tame spam using regex.
For me, this meant, that my mail client's spam filter only eliminated spam in my inbox, but none of them in my many subfolders (because sieve had already delivered them there, the sneaky bastard!). This, essentially, rendered some lists (i.e. ds@ccc.de) unusable. However, deactivating the sieve filter wasn't an option, either. My inbox would simply be swamped with list mails if I would have to read them via webmail for a while.
The solution to this dilemma, was rather easy in the end and one of those things that I had been procrastinating for months and then just took a mere minutes. The idea is to let Spamassassin tag each message with a Spam-Score header and then let sieve filter out messages according to that score. The problem was, though, that for some unfathomable reason sieves numerical comparator cannot deal with negative values, so lots of list traffic with highly negative spam scores would falsely be locked away without trial. Outrage!
Well, all you really got to do is check for the occurrence of the '-' character in advance and then use the 'discard' action, if appropriate. So here's the beginning of my personal sieve script that's now keeping my inbox nice and clean. Whereas previously I would have to deal with ca. 200+ spam mails per day in my junk box and mailinglists (plus ca. 10 to 20 that actually ended up in my inbox) I now get about 10 to 15 in the junkbox and just a couple in the inbox and lists. Hooray! I feel like I've rediscovered email again. It's become really useable now!
if not header :contains "X-Spam-Score" "-" {
if header :value "ge" :comparator "i;ascii-numeric" \
["X-Spam-Score"] ["10"]
{
discard;
stop;
}
if header :value "ge" :comparator "i;ascii-numeric" \
["X-Spam-Score"] ["6"]
{
fileinto "INBOX.Junk";
stop;
}
}


Re: Spamfiltering using Spamassassin and sieve
Instead of filtering numerically, you can also (ab) use the "*" produced in the "X-Spam-Level" header (I guess that's the default name).
I check in two levels: if the mail has eight or more stars, move it into a "spam-eight" folder; then, if it has four or more stars, move it into a "spam-four" folder.
Of course, you would usually delete the "high score" spam - I just keep it as a reference for research purposes.
-- Matthias