Send off spam using Linux

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
$ make

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 < spam.txt

The e-mail will be written to the screen. Scroll back to the top of the e-mail and you will see some headers attached by SpamAssassin that are similar to the following:

X-Spam-Flag: YES
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.

Filtering spam

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.

KMail

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 “” “matches regular exp.” “.” and set the filter action to “pipe through”. Set the command to “spamassassin”. Uncheck the “If this filter matches” box. Click the Apply button to save the filter. This filter will run SpamAssassin on all incoming e-mail because the criteria will be true for any message.

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

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.

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Alastair Cousins

PC World
Show Comments

Cool Tech

SanDisk MicroSDXC™ for Nintendo® Switch™

Learn more >

Breitling Superocean Heritage Chronographe 44

Learn more >

Toys for Boys

Family Friendly

Panasonic 4K UHD Blu-Ray Player and Full HD Recorder with Netflix - UBT1GL-K

Learn more >

Stocking Stuffer

Razer DeathAdder Expert Ergonomic Gaming Mouse

Learn more >

Christmas Gift Guide

Click for more ›

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?