Scott Hurring » HOWTO » Postfix: Using spamassassin 'spamd'

HOWTO
info
Updated: Nov 06, 2005

Problem

I wanted to configure a debian postfix server to filter all email through SpamAssassin using spamd and spamc before delivering it to Exchange.

I did not want to use procmail or custom filter shell scripts. I did not want to do LDAP/Active Directory lookups of valid email addresses.

Becuase the company is a relatively small one, all valid internal email addresses are whitelisted on the postfix mailserver, anything not matching the whitelist is REJECTed. When the company grows more, we will be forced to switch to a more dynamic solution (i.e. lookup addresses on the ActiveDirectory server).

Solution

1. Make sure postfix works properly

As many, many other people have said before, do NOT try and do a fresh install of postfix and spamassassin at the same time. Get postfix configured and running the way you want first. Then, once you're confident that postfix is working fine without spamassassin, move on...

2. Fire up spamd

For debian, install the spamassassin package and the commandline client apt-get install spamassassin spamc

Then edit /etc/default/spamassassin and set ENABLED=1 and start the daemon /etc/init.d/spamassassin start

3. Tell postfix to use spamassassin

In master.cf, add -o content_filter=spamassassin
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (50)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd                
          -o content_filter=spamassassin
Then, at the end of the file, you must tell postfix what the content filter "spamassassin" should do. Add the following lines:
spamassassin unix -     n       n       -       -       pipe
        user=nobody argv=/usr/bin/spamc -f -e
        /usr/sbin/sendmail -oi -f ${sender} ${recipient}

4. Inspect the incoming mail headers

Restart postfix and send yourself some test messages. In the header section you should see spamassassin lines similar to
X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on server.com
X-Spam-Level:  
X-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_01,
        DATE_IN_PAST_96_XX,HTML_MESSAGE autolearn=no version=2.64

Notes

Example files

Software Used