My previous experiences with spam filtering with KMail have been bad. Its default configuration for Spamassassin is stupid: it pipes message through spamassassin itself, even though the Spamassassin daemon is running and I know it knows its there because it told me it had found it in the spam filtering wizard. The result is that KMail runs very, very slowly when filtering messages. The other annoying thing it does is play the mail notification sound even when the message is spam.

So I spent a little time working this out more carefully and now have the following filters in ~/.kde/share/config/kmailrc. Before describing them, though, the first important thing to note is that I've switched off the "play a sound" option in the "system notifications" section in the KDE control centre.

[Filter #0]

Applicability=0

AutomaticName=false

ConfigureShortcut=false

ConfigureToolbar=false

Icon=

StopProcessingHere=true

accounts-set=

action-args-0=/usr/share/sounds/KDE_Notify.wav

action-name-0=play sound

actions=1

apply-on=check-mail

contentsA=is in address book

fieldA=From

funcA=is-in-addressbook

name=Avoid Filtering Known Senders

operator=and

rules=1

First, if a mail comes from someone in my address book, then play a sound and stop processing filters. This means that I avoid running spamassassin unnecessarily and get useful audio notification.

[Filter #1]

Applicability=2

AutomaticName=false

ConfigureShortcut=false

ConfigureToolbar=false

Icon=

StopProcessingHere=true

accounts-set=111103578

action-args-0=Spam

action-name-0=transfer

actions=1

apply-on=check-mail,manual-filtering

contentsA=YES

fieldA=X-UEA-Spam-Flag

funcA=contains

name=UEA Spam

operator=and

rules=1

Next, (this one is pretty specific to me) if the UEA mail server has assigned a spam flag to the message, send it straight to the spam folder and don't process any further filters. Again, it avoids passing it through Spamassassin and avoids playing a sound.

[Filter #2]

Applicability=0

AutomaticName=false

ConfigureShortcut=false

ConfigureToolbar=false

Icon=

StopProcessingHere=false

accounts-set=

action-args-0=spamc -L

action-name-0=filter app

actions=1

apply-on=check-mail,manual-filtering

contentsA=256000

fieldA=

funcA=less-or-equal

name=SpamAssassin Check

operator=and

rules=1

If the message gets here then it is sent through Spamassassin. By default, KMail piped it through spamassassin, so it was just a matter of changing the argument to "pipe through" to "spamc -L" to make it run a bit faster.

[Filter #3]

Applicability=0

AutomaticName=false

ConfigureShortcut=false

ConfigureToolbar=false

Icon=

StopProcessingHere=false

accounts-set=

action-args-0=Spam

action-args-1=P

action-args-2=R

action-name-0=transfer

action-name-1=set status

action-name-2=set status

actions=3

apply-on=check-mail,manual-filtering

contentsA=yes

fieldA=X-Spam-Flag

funcA=contains

name=Spam handling

operator=or

rules=1

This one KMail set up automatically. It just moves spam flagged messages to the spam folder.

[Filter #4]

Applicability=0

AutomaticName=false

ConfigureShortcut=false

ConfigureToolbar=false

Icon=

StopProcessingHere=true

accounts-set=

action-args-0=/usr/share/sounds/KDE_Notify.wav

action-name-0=play sound

actions=1

apply-on=check-mail,manual-filtering

contentsA=no

fieldA=X-Spam-Flag

funcA=contains

name=Notify Non-spam

operator=or

rules=1

This one I added. If Spamassassin decides the message isn't spam, then play a sound. Now I only get sound for messages from people in my address book and messages which Spamassassin thinks aren't spam.

There are two further "filters" which are not applied to incoming messages but which appear the context menu to help teach Spamassassin about spam. Again, they are created automatically by KMail.

It seems to be working all right so far :-)

Posted Wed 13 Jun 2007 17:15:00 BST

We had a man from ITCS in the Music department yesterday to talk about buying new kit. This is unremarkable except that he had no qualms about admitting, "I don't know the AHRC is". This is indicative of the state of research IT support at UEA; there simply is none.

Posted Wed 20 Jun 2007 09:25:00 BST