Book Image

SpamAssassin: A practical guide to integration and configuration

Book Image

SpamAssassin: A practical guide to integration and configuration

Overview of this book

As a busy administrator, you know Spam is a major distraction in todays network. The effects range from inappropriate content arriving in the mailboxes up to contact email addresses placed on a website being deluged with unsolicited mail, causing valid enquiries and sales leads to be lost and wasting employee time. The perception of the problem of spam is as big as the reality. In response to the growing problem of spam, a number of free and commercial applications and services have been developed to help network administrators and email users combat spam. Its up to you to choose and then get the most out of an antispam solution. Free to use, flexible, and effective, SpamAssassin has become the most popular open source antispam application. Its unique combination of power and flexibility make it the right choice. This book will now help you set up and optimize SpamAssassin for your network.
Table of Contents (24 chapters)
SpamAssassin
Credits
About the Author
About the Reviewers
Introduction
Glossary

Introduction

SpamAssassin is an open-source spam detector. It is considered the best of breed, and is used by many large organizations and also as the basis for commercial services and products.

SpamAssassin is free to download, install, and use, and is very customizable, configurable, and scalable to large architectures. It can be installed in one afternoon, but rewards further time spent on improving the detection rate.

This book provides a complete guide to the installation, configuration, and customization of SpamAssassin. It also discusses the history of Spam and the various techniques used to combat it. It includes detailed instructions for the most popular Mail Transport Agents (MTAs): Sendmail, Postfix, Exim, and Qmail. It also includes details on installing SpamAssassin on Windows, and adding a separate spam filter to an existing email infrastructure, such as Microsoft Exchange.

Most spam detection systems use only one or two methods of detecting spam. SpamAssassin uses many, and is extensible, allowing users to develop their own rules to identify spam. New techniques to identify spam, such as Sender Policy Framework (SPF) can be added to SpamAssassin by developing them as modules. Users or System Administrators can configure almost every aspect of SpamAssassin, leading to exceptional success rates in detecting spam.

SpamAssassin is Open Source, which means that the program code is freely available for others to examine and modify. SpamAssassin is developed, documented, and supported by a team of volunteers who give their time freely.

What This Book Covers

This book has three main areas or sections. The first section discusses spam, spammers, and anti-spam techniques. The second section discusses SpamAssassin basics, including obtaining, installing, and configuring SpamAssassin. The final section describes techniques to improve the spam detection of SpamAssassin, and to improve the performance of a SpamAssassin installation.

Chapter 1 introduces spam and provides some definitions of terms used in this book.Chapter 2 discusses various spam detection techniques used by spam detection engines and the techniques developed by spammers to subvert them.

Chapter 3 discusses open relays, historically the source of much spam, and includes information on how to check that an existing email server cannot be abused by spammers. It also describes how to rectify an MTA that is acting as an open relay. Chapter 4 describes how spammers collect email addresses and provides solutions to publish email addresses on websites without making them targets for spam.Chapter 5 discusses the mechanics of detecting spam.

Chapter 6 gives detailed instructions on how to install SpamAssassin on Unix, Linux, and Windows platforms, including obtaining and installing any prerequisite packages that SpamAssassin requires.

Chapter 7 provides a brief run through the SpamAssassin configuration files, and provides a foundation for the remaining chapters. Chapter 8 discusses how to integrate SpamAssassin with the MTA, or invoke it using procmail. A variety of strategies are discussed, to suit the needs of different organizations.

Chapter 9 covers the use of SpamAssassin’s Bayesian filter, a tool that learns from spam emails and can improve detection rates dramatically.

SpamAssassin is incredibly flexible, and Chapter 10 discusses how SpamAssassin can alter emails to mark them as spam.Chapter 11 covers adding external Network Tests which utilize databases of known spam emails to improve spam detection rates.

Chapter 12 provides a description of SpamAssassin’s rules, and describes how rules can be written, tested, and scored.

Chapter 13 covers methods to improve the detection rate of SpamAssassin, including whitelists and blacklists.

Chapter 14 describes how to improve the performance of a SpamAssassin installation.

Chapter 15 describes some useful reports and utilities that an administrator can use to streamline the running of a SpamAssassin installation.

Chapter 16 has a complete description of how to create a spam filtering gateway—this covers installing Linux and SpamAssassin, and configuring them all to filter email and forward the non-spam (or ‘ham’) to the existing email server.

Chapter 17 describes how to configure several major email clients to filter email based on the tags that SpamAssassin places in emails.

Finally, Chapter 18 discusses the advantages, disadvantages, and options available when adding an additional spam filter to an existing SpamAssassin installation.

What You Need for Using This Book

SpamAssassin and all the tools it uses are available for download from the Internet. Perl, the main prerequisite, is included in all major Linux distributions and available for most Unix-like operating systems. It can be downloaded from http://www.perl.org/get.html. The Perl CPAN module is normally used to install SpamAssassin; all that is required is an Internet connection.

This book covers integrating with four of the most popular MTAs—Sendmail, Postfix, Exim, and Qmail. MTA integration is only a small part of this book, and most of this book will be relevant no matter which MTA is in use. SpamAssassin can be integrated with most MTAs.

Conventions

In this book you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

There are three styles for code listings. Code words within text are shown as follows: "Rather than get the contents of myFile with the getContents() method, we construct a new CmsXmlControlFile object".

If we have a block of code, it will be set as follows:

#!/usr/bin/perl -w
# spamlogfileparser.pl - parse /var/log/messages and calculate statistics
use strict;
# declare variables
my (@ham, @spam, %seen);

When we wish to draw your attention to a particular part of a code block, the relevant lines will be made bold:

#!/bin/sh
# check_process.sh check a process is running
[email protected]
if [[ $1 = "" ]]; then

New terms and important words are introduced in a bold-type font. Words that you see on the screen—in menus or dialog boxes, for example—appear in the text as follows: "Clicking the Next button moves you to the next screen".

Note

Tips, suggestions, or important notes appear in a box like this.

Any command-line input and output is written as follows:

mysql> create table books (name char(100), author char(50));
Query OK, 0 rows affected (0.03 sec)

Reader Feedback

Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an e-mail to , making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the Suggest a title form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code for the Book

Visit http://www.packtpub.com/support, and select this book from the list of titles to download any example code or extra resources for this book. The code files available for download will then be displayed.

Note

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and also help to improve subsequent versions of this book.

If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata have been verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Questions

You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address it.