Integration into Courier-MTA using maildrop
First, install SpamAssassin and Courier MTA according to their installation docs. Make sure they are functioning on their own. You may want to use spamc/spamd for better performance. What's left is the The connection between Courier and SpamAssassin.
Wiki Markup |
---|
If you have virtual users (as opposed to plain \*nix users), it is vital that you make sure that courier-mta (as well as courier-imap and courier-pop) uses the authdaemon as authentication module. That means that in {{/etc/courier/esmtpd}}, {{imapd}} and {{pop3d}} the variable AUTHMODULES should be set to {{"authdaemon"}}. Keep in mind that your courier config files may be in another directory. The authdaemon has to be configured to use the right authentication modules (mysql, userdb, whatever). Then patch [SpamAssassin] according to \[http://da.andaka.org/Doku/courier-spamassassin.html\] so that [SpamAssassin] can ask authdaemon for the whereabouts of the maildirs of virtual users (and plain users too --- but if you only have plain users, you may skip this step). |
is made by using maildrop as the MDA and spamd/spamc to perform the spam checking using Courier's mail filtering language.
To let Courier To let Courier MTA use maildrop as default for delivery, edit /etc/courier/courierd
and set DEFAULTDELIVERY
to "| /usr/bin/maildrop"
(or whereever wherever your maildrop binary is). Then edit the global filter file /etc/courier/maildroprc
, the central maildrop script to pipe mail through Spamassassin before delivery:
No Format |
---|
exceptionimport {USER if ($LOGNAME ne "") { xfilter "/usr/bin/vendor_perl/spamc -u $LOGNAME" } exception else { xfilter "/usr/bin/vendor_perl/spamc -u $USER" } |
You must then decide what to do with any spam mail. For example, an instruction in the the users .mailfilter file:
No Format |
---|
if(/^X-Spam-Status: include YES/) { to "$HOME/Maildir/.mailfilterJunk/" } |
If you have virtual users (as opposed to plain *nix users) you may want to let Spamassassin know where to find per-user preferences. Do this by passing the username to spamc with the -u option and then using the spamd --virtual-config-dir option, for example in a systemd service file (where vmail is the virtual mail user):
No Format |
---|
ExecStart=/usr/bin/vendor_perl/spamd -x -u vmail -g vmail --virtual-config-dir=/home/vmail/%%d/%%l |
You can omit this if using only system-wide preferencesVia the xfilter line, maildrop pipes its contents through spamc; via the include line, the user's mailfilter script is called.