Combining Exim4 with Spamassassin


This page describes how I set up my system to handle my e-mail. In particular it deals with processing the mail after it has been retrieved from a POP server by fetchmail. I use Exim4 as local MTA. Exim4 sends all incoming mail to Spamassassin. If Spamassassin considers the mail spam, Exim4 will put it in ~/Maildir/Spam/ instead of the usual ~/Maildir/. Finally, I run dovecot as an IMAP server, so that I can access my mail from any computer running an e-mail client that understands IMAP.

So in a nut shell: e-mail

  1. arrives on POP server
  2. is transferred by fetchmail to Exim4 on local machine
  3. is sent by Exim4 to Spamassassin
  4. is processed by Spamassassin and sent back to Exim4
  5. is sent to ~/Maildir (regular mail) or ~/Maildir/Spam (spam)
  6. is accessible to e-mail clients on either the local machine or other computers via dovecot (IMAP)

To have all this running, you will need (at least) the following packages (package names refer to Debian sid)

All configuration issues hold for Debian sid. It is probably similar on other distributions and may be useful for setting up Exim4 + Spamassassin on non-Debian systems too.

Changes to the default Exim4 setup

Changes to the default Spamassassin setup

The Debian spamassassin package contains a program spamd which can run as a daemon. However this is disabled by default and you should edit /etc/default/spamassassin to enable it. I also removed the "-c" from the OPTIONS in the file, because Spamassassin will not run under the user account and as such is not going to use the user preferences.

Update 8 March 2004
Janos Dobos from Hungary mailed me the following comment: if you set up the spamcheck transport with this modification:

      ---     transport_filter = /usr/bin/spamc
      +++     transport_filter = /usr/bin/spamc -u ${local_part}
then spamc will run under the user account of the local part of the emailaddress. In most cases the local part is the name of the actual localuser thus spamc can use the user preferences. (Actually spamc runs as Debian-exim/Debian-exim but spamd runs as root so can drop into group/user and access the neccessary files.)
I am not using this myself, but if you do not have root access or do not want to change the Debian defaults, you might want to try this.

Dealing with spam

Messages are just marked as spam at this point - they are not treated any differently than other mail. If you would like to put them in a separate folder, you can use Exim4's filters. You should make the following changes.

Acknowledgements and links

The information on this page is mostly an update of the information provided by Derrick Hudson on Unfortunately, this site seems to be unreachable.

If you want you can also simply refuse to accept spam messages sent to you (since my e-mail is accepted by a POP server that I do not have administrator rights for, this is not useful for me). If you would like to take this approach, please check Marc Merlins site on sa-exim.

Updated 9 October 2003:
The output Spamassassin adds to e-mail changed and would cause the original Exim filter to put all mail in the Spam folder. Changed the check to be case sensitive. Thanks to Damir for pointing that out.

Updated 16 December 2003:
The Debian developer maintaining exim4 has changed the user and group for the exim4 program from mail to Debian-exim which caused the spamcheck transport filter to fail.

Martijn Anthonissen, 8 March 2004