Installing Postfix, SpamAssassin, ClamAV, and qpsmtpd

From Dev411: The Code Wiki

Postfix is gaining popularity as a MTA. This page shows how to configure Postfix with SpamAssassin spam checking and ClamAV antivirus using qpsmtpd as the SMTP server. qpsmtpd is an ideal way to filter email using SpamAssassin, ClamAV and many other methods keeping the load off of Postfix.

This page is in the process of being built.

Installing Postfix

First install PCRE and then install Postfix using:

# groupadd postfix
# useradd -g postfix -d /home/postfix -s /bin/false postfix
# groupadd postdrop
$ make
# make install

Edit the aliases file and send root's email to a different user account. Find the aliases file by using postconf alias_map. Then set a line like 'root:mark'. The reload Postfix:

# new aliases
# postfix reload

Once qpsmtpd is installed, have qpsmtpd listen on port 25 instead of Postfix. To do this on select interfaces edit the the /etc/postfix/main.cf file. To do this on all interfaces, edit the /etc/postfix.master.cf file and comment out the 'smtpd inet' line.

Installing qpsmtpd

qpsmtpd requires a few Perl modules: Net::DNS, MIME::Base64 and Mail::Header. These should be installed before qpsmtpd.

qpsmtpd can be installed via a tarball, RPM or .deb package. This page covers installation via tarball which is done by creating a *nix user and extracting the files into a directory. To use the qpsmtpd Postfix plugin, the *nix user needs to be a member of the postdrop group.

# useradd -g postdrop -d /home/smtpd -s /bin/false smtpd
# su -smtpd
$ cp /tmp/qpsmtpd-0.32.tar.gz .
$ tar -xvf qpsmtpd-0.32.tar
$ ln -s qpsmtpd-0.32 qpsmtpd
$ mkdir tmp
$ cd qpsmtpd
$ mv config.sample config
$ perl -pi.bak -e 's|^queue/qmail-queue$|queue/postfix-queue|m' plugins

There are several ways to deploy qpsmtpd including: forkserver, Apache::Qpsmtpd, tcpserver and pollserver. PPerl is an old deployment method that should not be used any more. forkserver and Apache::Qpsmtpd are popular deployment methods.