In this tutorial we’ll install the Debian Linux 9 (squeeze), Apache 2 with mpm-itk (to run each web as a isolated user),...
Installing and configuring MailScanner for virus and spam filtering (Postfix, ClamAV, SpamAssassin, Razor)
Ástþór IPMailScanner is an e-mail security and anti-spam package for e-mail gateway systems. MailScanner is highly configurable using a very easy-to-use system of rulesets. Virtually every configuration option can, for example, be controlled on a per-user, per-domain or per-IP basis.
It’s assumed that you have already installed and configured Postfix according to this tutorial:
Installing Postfix with MySql backend and SASL for SMTP authentication
1. Add backports to your apt sources (pico /etc/apt/sources.list)
deb http://www.backports.org/debian lenny-backports main contrib non-free
2. Add the backports keyring and update apt
apt-get update
apt-get install debian-backports-keyring
apt-get update
3. Install required packages (ClamAV, SpamAssassin, Razor and required libs for MailScanner)
apt-get install clamav clamav-base clamav-freshclam libclamav6 spamassassin razor unzip libarchive-zip-perl libconvert-tnef-perl libhtml-parser-perl libmime-tools-perl libmime-perl libcompress-zlib-perl libconvert-binhex-perl libdbd-sqlite3-perl libfilesys-df-perl libsys-syslog-perl libsys-hostname-long-perl libmailtools-perl libole-storage-lite-perl libnet-cidr-perl
4. Install libnet-dns-perl from backports
apt-get -t lenny-backports install libnet-dns-perl
5. Install MailScanner
apt-get install mailscanner
6. Enable MailScanner (pico /etc/default/mailscanner)
run_mailscanner=1
7. Edit MailScanner configuration (pico /etc/MailScanner/MailScanner.conf)
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Always Include SpamAssassin Report = yes
Send Notices = no
Spam List = RFC-IGNORANT-DSN SORBS-SMTP spamhaus-ZEN spamcop.net CBL
Spam Lists To Reach High Score = 2
High SpamAssassin Score = 8
Rebuild Bayes Every = 86400
Wait During Bayes Rebuild = yes
High Scoring Spam Actions = delete
8. Create razorhome, discover razor servers and register for identify
razor-admin -create
razor-admin -register
9. Make Postfix put all messages on hold to allow MailScanner to scan the messages (pico /etc/postfix/main.cf)
header_checks = regexp:/etc/postfix/header_checks
10. Create the header checks file referenced by previous line (pico /etc/postfix/header_checks)
/^Received:/ HOLD
11. Restart MailScanner and Postfix
/etc/init.d/mailscanner restart
postfix reload