Chapter 6. Fighting spam

Table of Contents

6.1. ClamAV
6.2. SpamAssassin
6.2.1. Training SpamAssassin
6.2.2. Move Bayes and AWL data to MySQL
6.3. Amavisd-new
6.3.1. Store configuration in a database
6.3.2. Maintenance
6.3.3. Utilities
6.4. DKIM
6.4.1. DKIM check for incoming emails
6.4.2. Signing your outgoing mail
6.5. RBL lists
6.6. Greylisting
6.7. SPF

Amavisd-new is a program that receives mail from Postfix, passes it through SpamAssassin and ClamAV and based on the user (or global) settings decides if the mail should be flagged as a spam, deleted or delivered as a legitimate mail.

We are going to install all of the packages at once.

apt-get install amavisd-new spamassassin clamav-daemon

6.1. ClamAV

ClamAV needs some utilities that are not provided in the mail Debian repository. This utillities will be used to extract email attachments so the content of the archives can be scanned for potential viruses.

Because of this utillites we need to add contrib and non-free repositories to the /etc/apt/sources.list. To do this you have to append ”contrib non-free” on every line that starts with deb, and ends with main. Your /etc/apt/sources.list file should look like this:

deb http://ftp2.de.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp2.de.debian.org/debian/ squeeze main

deb http://security.debian.org/ squeeze/updates main contrib non-free
deb-src http://security.debian.org/ squeeze/updates main

deb http://ftp2.de.debian.org/debian/ squeeze-updates main contrib non-free
deb-src http://ftp2.de.debian.org/debian/ squeeze-updates main

After editing /etc/apt/sources.list commit the changes you made to sources.list with etckeeper. Now we need to update the apt database. While we are at it we can also check if there are any packages that should be updated.

apt-get update
apt-get upgrade

Now we are ready to install utilities for decompression of archives.

apt-get install arj bzip2 cabextract cpio file gzip lha nomarch pax rar unrar unzip zip zoo

Add clamav user to the amavis group and vice versa in order for Clamav to have access to scan files:

adduser clamav amavis
adduser amavis clamav

Restart amavis and clamav-daemon.

/etc/init.d/clamav-daemon restart
/etc/init.d/amavis restart