Installing SpamAssassin is very straight forward. It does however have dependancies. Just like with amavisd-new, we can take care of these with the perl CPAN interface. First of all, lets start up the CPAN shell and get all the prerequisites installed.

enter the CPAN shell with :

sudo perl -MCPAN -e shell

Then we install the following packages. Remember to let it install and sub-dependancies by hitting enter when asked.

install YAML
install HTTP::Date
install LWP
install Net::DNS
install NetAddr::IP
install Digest::SHA1
install HTML::Parser
install IO::Zlib
install Archive::Tar
install HTML::Parser
install DB_File
install IO::Socket::SSL
install Mail::SPF
install IP::Country
install Net::Ident
install Mail::DKIM
install Encode::Detect

Now that the ground work is done, we need to get the latest source from When we build SpamAssassin it will ask for an email2 address to be used in suspected-spam reports. You may enter any email2 you like, though I would suggest you use your postmaster account.

Expand the archive and build SpamAssassin using the following commands :

tar -xvf Mail-SpamAssassin-3.3.1.tar.bz2
cd Mail-SpamAssassin-3.3.1
perl Makefile.PL
make test
sudo make install

Now that it is installed, we need to configure it. SpamAssassin has placed all its configuration files in /etc/mail2/spamassassin/. By default there are 6 files in there, and each one is read in turn. Because we have not installed the Razor2 program the help SpamAssassin we have to disable the code that calls it.

Open the file /etc/mail2/spamassassin/v310.pre and comment out line 32.
from :

loadplugin Mail::SpamAssassin::Plugin::Razor2


# loadplugin Mail::SpamAssassin::Plugin::Razor2

Now that that is done, the last thing to do is to get the spam rules for SpamAssassin to use. That is a single command :

sudo sa-update -D --nogpg

This will fetch and install a bunch of spam rules for SpamAssassin to work with. You can add your own rules, and you can train SpamAssassin for ham and spam as well. Please see the SpamAssassin documentation for more details.