Stop spam the expert way: Build an anti-spam email server

It is relatively easy to retro-fit a working mail server with some highly accurate anti-spam measures. Some measures will work with any system, while there are also some specific changes you can make to particular mail server programs. We will concentrate on the general methods that can be applied to any regular email server, be it Sendmail, Postfix or Qmail.

Stop spam the expert way: Build an anti-spam email server

Of course, we are presuming you already have an email server: building one from scratch is beyond the scope of this article. Even if you do not intend to build your own, these two pages will illustrate exactly why so many individuals and small businesses dedicate one machine to handle email.

Is it safe?

Now would be a good time to test your email server to ensure it is not an open relay. If it is, it could be abused by a spammer and ordered to send spam to other systems without your permission. One easy way to find out is to log in to the email server and run the following command from the command line:


This will initiate a series of tests where the server tries to discover ways in which your email server could be abused. The results will look similar to this:


>> mail from: >> rcpt to:

: Relay access denied

If any of the tests show that relaying is possible, you need to reconfigure your email server before continuing.

What have you got?

We are assuming that your email server runs a popular mail server. In our example, we have used Postfix running on SuSE Linux 9, but these instructions should apply to other setups too. We are going to use SpamAssassin to detect incoming spam and Procmail to help filter it. You will need to install both of these programs, although Procmail is probably already available on your system. You can check for both programs by typing the following at the command line:

rpm -q procmail

rpm -q spamassassin

This should list the versions of Procmail and SpamAssasin you have installed.

We will assume you already have Procmail but do not have SpamAssassin available. If you do not have Procmail, you can download it from You will also need Perl.

Setting up SpamAssasin

The first step is to install SpamAssassin. There are a number of ways you can implement this anti-spam system, and we are going to use one of the fastest and most efficient methods. Instead of loading the entire SpamAssassin program each time it is required, a smaller client program called spamc is used. This talks to the SpamAssassin daemon called spamd, which runs on the system all the time.

Downoad and install SpamAssassin. The source code is available from and is less than 1MB. Once saved to your hard disk, extract the files into a directory that will be called something like Mail-SpamAssassin-3.0.2, depending on the exact release. In our case, we downloaded Mail-SpamAssassin-3.0.0-3.tar.gz and extracted the files by typing:

gunzip Mail-SpamAssassin-3.0.0-3.tar.gz

tar -xvf Mail-SpamAssassin-3.0.0-3.tar

This created a directory called Mail-SpamAssassin-3.0.0-3 containing the source code. We compiled the program and installed it by typing the following:

cd Mail-SpamAssassin-3.0.0-3

perl Makefile.PL

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.

Todays Highlights
How to See Google Search History
how to download photos from google photos