If you’ve had an e-mail address for some time, chances are you have been the victim of unsolicited junk e-mail — otherwise known as spam. Removing spam can become a tiresome chore, and filtering for it using traditional filters is often ineffective and complicated. Over the next two columns we will look at some effective methods to filter spam from your inbox.
Included on this month’s cover CD is a copy of SpamAssassin (www.spamassassin.org), an intelligent spam detection tool which employs a variety of methods to identify e-mail as spam. Using a scoring system, SpamAssassin assigns points for various common characteristics of spam to generate a total score for each e-mail you receive.
If an e-mail crosses a threshold score (by default, 5 points) it is marked as spam. Examples of point scoring offences include falsified e-mail headers, repeated phrases and misuse of HTML. SpamAssassin attaches a report to the top of a spam e-mail providing a breakdown of the reasons for the classification.
To compile SpamAssassin, copy the file from the cover CD to your hard disk and type the following commands in a shell:
$ tar xvfz Mail-SpamAssassin-2.53.tar.gz
$ cd Mail-SpamAssassin-2.53/
$ perl Makefile.PL
To install SpamAssassin, change to the superuser using the ‘su’ command and type the following:
$ make install
If you wish to test SpamAssassin, save a spam e-mail you have received to a file and call it spam.txt. To test SpamAssassin, type in a shell:
$ spamassassin X-Spam-Status: Yes, hits=6.3 required=5.0
These headers indicate the e-mail was classified as spam because it scored 6.3 points, more than the required 5.0. Below these headers is a full breakdown of the points scored by the e-mail.
Now that SpamAssassin is installed and working, you can begin employing it to filter incoming spam. Before configuring your e-mail client to use SpamAssassin, you should create a folder in which to store identified spam. Although SpamAssassin is very good at differentiating between spam and normal e-mail, occasionally it can be wrong. Maintaining a separate spam folder gives you a second chance to identify any normal e-mail mistakenly classified as spam.
You’ll find instructions for configuring KMail and Evolution to use SpamAssassin below, but users of other e-mail clients should be able to adapt these instructions for their own clients.
To configure KMail to use SpamAssassin, you need to create two filters by selecting Settings-Configure Filters from the menu. Click the New button located in the lower left corner to create a new filter. The first filter should be added at the top of your filter list so that it is the first to process new e-mails.
Set the filter criteria to “
The second filter should follow the newly created SpamAssassin filter and will move e-mail classified as spam into your spam folder. Create a new filter and set the criteria to “X-Spam-Flag” “equals” “YES” and set the action to “move to folder”. Set the folder to your spam folder.
Evolution does not allow an external command to modify an e-mail, so you must use SpamAssassin in a slightly different way. SpamAssassin can be made to return a simple true/false verdict with the addition of a “-e” switch to the spamassassin command.
To create a filter in Evolution, select Tools-Filters from the menu. Click the Add button and title the filter ‘SpamAssassin’. Set the criteria located in the top half of the window to “Pipe Message To Shell Command” “spamassassin -e”. Set the next box to “returns greater than” and set the final value to “0”. In the Action box located below, set the action to “Move to Folder” and select the “Spam” folder from the available list. To save the filter, click the OK button.
Now all that’s left to do is to sit back and wait for a spam to arrive. In the future you should see all your spam piling up in the new spam folder. In next month’s Linux Here’s How we’ll look at configuring SpamAssassin to be more precise, as well as using SpamAssassin with the procmail e-mail filter.