Introduction
In this howto, Postfix integration witch Amavis-new will be presented. Amavis-new is a wrapper that can call spam detection, antivirus, etc. In this howto, integration witch spamassassin and Clamav will be presented. This is a quite classical installation of Postfix + amavis-new + spamassassin + clamav.
Please note that the packages amavisd-new, clamav, spamassassin are part of the ["UniversePackages"]. That means they will not receive security support from canonical. You are warned.
Prerequisite
Postfix should be functional on your server. If it is not the case, follow the ["Postfix"] howto.
Installation
Activate Universe and Multiverse repositories. Just follow this howto: ["AddingRepositoriesHowto"]. Wee explains why Universe in the Introduction, multiverse will be necessary for some compress/uncompress utils.
For beginning, install the main components of the mail filtering system:
sudo apt-get install amavisd-new spamassassin clamav-daemon clamav-freshclam
Install the optionnal packages for better spam detection (who does not want better spam detection?)
sudo apt-get install libnet-dns-perl libmail-spf-query pyzor razor
Install some compress/uncompress utils
sudo apt-get install ar arj bzip2 cabextract cpio file gzip lha nomarch pax rar unarj unrar unzip unzoo zip zoo
Configuration
clamav
The default behaviour of clamav will fit our needs. A daemon is launched (clamd) and signatures are fetch every day. If you want to tun clamav functionnement, check configuration files in /etc/clamav.
Add clamav user in amavis in order clamav can access files:
sudo useradd clamav amavis
spamassassin
spamasssassin has a cool feature: it autodetects optionnal components and in case they are presents; it use it. It results there is no need to configure dcc-client, pyzor and razor.
We will not talk about fine tuning of spamassassin rules here. Please refer to the ["Spamassassin"] page.
Edit /etc/default/spamassassin to activate daemon file:
8<----------------------------------------- # Change to one to enable spamd ENABLED=1 8<-----------------------------------------
amavis
First, activate spam detection and antivirus detection in amavis by editing /etc/amavis/conf.d/15-content_filter_mode:
use strict; # You can modify this file to re-enable SPAM checking through spamassassin # and to re-enable antivirus checking. # # Default antivirus checking mode # Uncomment the two lines below to enable it back # @bypass_virus_checks_maps = ( \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re); # # Default SPAM checking mode # Uncomment the two lines below to enable it back # @bypass_spam_checks_maps = ( \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re); 1; # insure a defined return
Postfix integration
For postfix integration, you only need to add in /etc/postfix/main.cf the following line:
content_filter=smtp-amavis:[127.0.0.1]:10024
Reload postfix, and now, content filtering with spam and virus detection is enabled.
Test
First, test that the amavis SMTP is listening:
telnet localhost 10024 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 [127.0.0.1] ESMTP amavisd-new service ready ^]
Check on your /var/log/mail.log that everything goes well. If you rise the log level, you can check every step of the content filtering: spam check, virus check, etc. Dot not forget to drop down the log level after your checks !
On messages that go through the content filter, you should see:
X-Spam-Level: X-Virus-Scanned: Debian amavisd-new at example.com X-Spam-Status: No, hits=-2.3 tagged_above=-1000.0 required=5.0 tests=AWL, BAYES_00 X-Spam-Level: