This page 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 Red Hat Enterprise Linux and CentOS and it’s ready to go out of the box. If it is not yet installed in your system, use the command below to install it.

yum install spamassassin

Configuring MailScanner

MailScanner Virus Config1. Edit the file /etc/MailScanner/virus.scanners.conf and change the path of clamav to /usr.
MailScanner Config2. 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
MTA = postfix
Incoming Work Group = clam
Incoming Work Permissions = 0640
Virus Scanners = clamd
Clamd Socket = /var/run/clamav/clamd.sock
Use SpamAssassin = yes
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
MailScanner Spool Directory
3. Setup the necessary directories using the commands below.
cd /var/spool/MailScanner/
mkdir spamassassin
chown -R postfix.clam *
chmod -R 750 *
restorecon -R ../MailScanner/
semodule freshclamtmp4. For RHEL/CentOS 6, configure SELinux using the commands below. Here’s the content of freshclamtmp.te
wget linuxmail.info/files/rhel6/freshclamtmp.te
checkmodule -M -m -o freshclamtmp.mod freshclamtmp.te
semodule_package -o freshclamtmp.pp -m freshclamtmp.mod
semodule -i freshclamtmp.pp

Integrating MailScanner into Postfix

Postfix Configuration1. Edit the file /etc/postfix/main.cf 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.
start MailScanner
3. MailScanner should now be the one to start the Postfix service. Stop the Postfix service and start the Clamd and MailScanner service in that order. Use the commands below to accomplish these.
chkconfig postfix off
chkconfig clamd on
chkconfig MailScanner on
service postfix stop
service clamd start
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/maillog.

Congratulations

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 4/25/2007 and last updated on 3/16/2012
Filed under Anti-spam/Anti-virus , CentOS 5 , CentOS 6 , MailScanner , Postfix , Red Hat Enterprise Linux 5 , Red Hat Enterprise Linux 6