This article will guide you in configuring MailScanner, ClamAV and SpamAssassin to work in Postfix. Before proceeding, please make sure that all of the above components are already installed.

Here are the installation guides for the above components.

SpamAssassin is included in CentOS 4 and ready to go out of the box. Just add it using the Package Management tool if you haven’t done so during CentOS installation. SpamAssassin is located in the Mail Server package.

Configuring MailScanner

MailScanner Config1. Edit the file /etc/MailScanner/MailScanner.conf
Find the following keys and change the values as follows
%org-name% = your organization name
%org-long-name% = your full organization name
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Virus Scanners = clamd
Clamd Socket = /tmp/clamd.socket
Use SpamAssassin = yes
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
MailScanner Spool Directory2. Click Applications and click File Browser to launch the File Browser window and go to the /var/spool/MailScanner directory.
MailScanner Spool Directory3. In the File Browser window, click File and click Create Folder. Name the new folder spamassassin.
MailScanner Spool Directory4. Right click on the folder incoming and click Properties.
MailScanner Directory Permission5. In the Properties window, click the Permissions tab. In the Permissions page, set the File owner as postfix, the File group as postfix and check only the Owner Read, Write and Execute. Click Close when you are done. Repeat this for the quarantine and spamassassin folders.

Integrating MailScanner into Postfix

Postfix Configuration1. Edit the file /etc/postfix/ and remove the # in front of the line below
header_checks = regexp:/etc/postfix/header_checks
Header Checks2. Edit the file /etc/postfix/header_checks and add the line below to the bottom of the file
/^Received:/ HOLD
This will now place all incoming mail into the holding area until released by MailScanner.
CentOS 4 Service Configuration3. MailScanner should now be the one to start the Postfix service. Stop the Postfix service and start the MailScanner service in that order. Learn how to stop and start services here.
Terminal4. Test if Postfix is still working. See Test Postfix using Telnet.


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.

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

Posted on 3/14/2007 and last updated on 11/7/2009
Filed under Anti-spam/Anti-virus , CentOS 4 , MailScanner , Postfix , Red Hat Enterprise Linux 4