September 2005


I am The Cyberwolfe and these are my ramblings. All original content is protected under a Creative Commons license - always ask first.
Creative Commons License

spam spam spam spam spam

You’ve heard me bitch recently about the sudden increase in 419 scam emails I have been receiving, and I finally got tired of deleting them by hand. Definitely time to give a spamkiller of some sort a try.

30 seconds of Googling later for “kmail+spam” gives me the idea that the best method for stemming the tide would be to install SpamAssassin (SA). Since I’m running a version of apt-get designed to work with SuSE, this was simply running Synaptic package manager and clicking a box.

The question then was, how do I get this thing working?

Read on to find out.

Unfortunately, the documentation at this point gets pretty fuzzy. The most common method described involved setting up another program, Procmail, to pre-filter email to a set folder and then process it through SA, and then create the final filter in Kmail. Thankfully, I have a Greyduck as a roomie who was able to shed a little light on the situation. Here’s what I ended up doing:

First, I went here and read his instructions. “Great!” I thought, “so that’s how you configure Kmail to use SA. But how do you configure SA in the first place?” Well, it turns out that SpamAssassin doesn’t really need any configuration other than to get the daemon running in the background. It is possible to just use the executable, but those who are in-the-know are saying this is inefficient. I configured the daemon as good practice.

Once you have SA installed, check /etc/init.d for an item called spamd. If it is there, SA should be installed correctly. Open a terminal and type su and then enter the root password. Now type chkconfig spamd. It will probably say ‘off’. If so, type chkconfig spamd on and hit Enter. Now reboot.

What that just did was adjust the settings for SA’s daemon mode, telling the computer to run the daemon at boot time. Typing chkconfig --list will show you a list of all daemons installed in the system and under what runlevels they are active, if you’re interested in that sort of thing. Note that most Linux systems use runlevel 5 for multi-user gui with networking.

Ok, now that you’ve rebooted, we need to create a folder in your Kmail local folders and call it Spam. The filters will send all of the spam here instead of just deleting it outright, since no method is perfect. There are a couple of simple commands you can use to teach SA about your email.

Now to configure the filters in Kmail. There are two that you need. The first will send all email through SA, and if SA thinks a message is spammy, it will set an ‘X-Spam-Flag’ to ‘Yes’. Otherwise, it will leave it alone. This change occurs in the header, and you won’t see it unless you view the message source.

The second filter then sends all email with ‘X-Spam-Flag: Yes’ to that Spam folder we created, leaving everything else in the Inbox or wherever else you have it set up to go. (I myself have three different Inboxes, one for each of the identities I set up in Kmail. Hi, I’m schizophrenic and so am I.)

For a final bit of assurance that I wouldn’t miss any good emails, I set up a third filter – a whitelist. We all know what a blacklist is, right? Well, a whitelist is the reverse. This filter scans the ‘From’ address and matches it to my address book. On a positive match, it marks the message as ‘Ham’ (as opposed to Spam) and stops processing the email through any more filters. Here’s how:

Filter Criteria:
Check “Match All of the following:” and set the first drop-down to “From” and the second drop-down to “is in address book”

Filter Actions:
Set the first drop-down to “Marks As” and the second to “Ham”

Now set “If this filter matches, stop processing here.” and move the filter to the top of the list.

That should do it. That wasn’t so hard, now was it?

Of course, I may not have things set up correctly at all. Only time will tell, but I will update if I had to change anything. For those of you using Windows, I am told that Mozilla Thunderbird has very similar tools built right into it, and there should be documentation on how to build the filters.

May the Spam be not with you.

Comments are closed.