Howto – Postfix

Using MailScanner with Postfix

Postfix can be handled slightly differently from the other supported mail systems, as one copy of Postfix can handle both the incoming mail via SMTP, and the outgoing mail by doing all the delivery.

How to Set Up Postfix for MailScanner Use
– Install Postfix and get the basics working

– Make sure you have the chroot jail set up in /var/spool/postfix. You should be able to see “etc”, “usr” and “lib” directories inside /var/spool/postfix. If you haven’t got the chroot jail setup already, then look in the “examples” directory of the Postfix documentation and you will find a script in there to set up it up for your operating system.

– In the Postfix configuration file /etc/postfix/ add this line:
header_checks = regexp:/etc/postfix/header_checks
– In the file /etc/postfix/header_checks add this line:
/^Received:/ HOLD

The effect of this is to tell Postfix to move all messages to the HOLD queue.

How to Set up MailScanner for Use with Postfix

In your MailScanner.conf file (probably in /etc/MailScanner or /opt/MailScanner/etc), there are 5 settings you need to change. They are all really near the top of the file. The settings are:

Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix

You will need to ensure that the user “postfix” can write to /var/spool/MailScanner/incoming and /var/spool/MailScanner/quarantine:

chown postfix.postfix /var/spool/MailScanner/incoming
chown postfix.postfix /var/spool/MailScanner/quarantine

Starting It All Running
Most systems MailScanner can be restarted with one of the following commands:

Most RPM based systems:
service mailscanner restart

Most Debian based systems:
service mailscanner restart

If you have configured everything correctly, MailScanner should restart Postfix for you.


A Footnote
You may have read somewhere on that MailScanner shouldn’t be used with Postfix. This is not true.  MailScanner as of 5.1.1-1 now supports a milter for those that need this functionality and will not directly interact with postfix queues in milter mode.  Even so, even in a traditional configuration as shown here, the bottom line is that MailScanner has worked flawlessly with Postfix for over a decade.