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

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 PC World newsletter!

Error: Please check your email address.

Our Back to Business guide highlights the best products for you to boost your productivity at home, on the road, at the office, or in the classroom.

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Alastair Cousins

PC World
Show Comments

Essentials

Microsoft L5V-00027 Sculpt Ergonomic Keyboard Desktop

Learn more >

Lexar® JumpDrive® S57 USB 3.0 flash drive

Learn more >

Mobile

Lexar® JumpDrive® S45 USB 3.0 flash drive 

Learn more >

Exec

Lexar® Professional 1800x microSDHC™/microSDXC™ UHS-II cards 

Learn more >

Audio-Technica ATH-ANC70 Noise Cancelling Headphones

Learn more >

Lexar® JumpDrive® C20c USB Type-C flash drive 

Learn more >

HD Pan/Tilt Wi-Fi Camera with Night Vision NC450

Learn more >

Budget

Back To Business Guide

Click for more ›

Most Popular Reviews

Latest News Articles

Resources

PCW Evaluation Team

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Aysha Strobbe

Windows 10 / HP Spectre x360

Ultimately, I think the Windows 10 environment is excellent for me as it caters for so many different uses. The inclusion of the Xbox app is also great for when you need some downtime too!

Mark Escubio

Windows 10 / Lenovo Yoga 910

For me, the Xbox Play Anywhere is a great new feature as it allows you to play your current Xbox games with higher resolutions and better graphics without forking out extra cash for another copy. Although available titles are still scarce, but I’m sure it will grow in time.

Kathy Cassidy

STYLISTIC Q702

First impression on unpacking the Q702 test unit was the solid feel and clean, minimalist styling.

Anthony Grifoni

STYLISTIC Q572

For work use, Microsoft Word and Excel programs pre-installed on the device are adequate for preparing short documents.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?