This page will guide you in configuring MailScanner, ClamAV and SpamAssassin to work in Postfix. Before proceeding, make sure Postfix is installed and working.

Configuring MailScanner

Install MailScanner1. Install MailScanner using the command below.
sudo apt-get install mailscanner
MailScanner Virus Config2. Edit the file /etc/MailScanner/virus.scanners.conf and change the path of clamav to /usr.
MailScanner Config3. Edit the file /etc/MailScanner/MailScanner.conf and update the lines below.
%org-name% = your organization name
%org-long-name% = your full organization name
%web-site% = your mail support website or company website
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
Incoming Work Group = clamav
Incoming Work Permissions = 0640
MTA = postfix
Virus Scanners = clamd
Use SpamAssassin = yes
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
Edit mailscanner4. Edit the file /etc/default/mailScanner and update the line below
Edit mailscanner5. Edit the file /usr/sbin/mailscanner and add a -U parameter on the first line.

Integrating MailScanner into Postfix

Postfix Configuration1. Edit the file /etc/postfix/ and add the line below
header_checks = regexp:/etc/postfix/header_checks
Header Checks2. Create the file /etc/postfix/header_checks and add the line below
/^Received:/ HOLD
This will now place all incoming mail into the holding area until released by MailScanner.
start MailScanner
3. Use the commands below to start MailScanner.
sudo service postfix restart
sudo service clamav-daemon start
sudo service mailscanner start
Terminal4. Test if Postfix is still working. See Test Postfix using Telnet.
NoteIf you encounter any problems, check the log file at /var/log/mail.log.


Congratulations, your mails are now checked for spam and viruses. Each mail you send or receive will now contain the lines below to indicate that MailScanner is doing its job.

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
NoteThe English language message templates used in MailScanner is stored in /etc/MailScanner/reports/en and can even be configured to add a disclaimer message to outgoing mails.

Visit the forum to ask for help or to give a comment.

Posted on 9/18/2011 and last updated on 9/18/2011
Filed under Anti-spam/Anti-virus , MailScanner , Postfix , Ubuntu 10.04