Integration into Courier-MTA using maildrop
The connection between Courier and SpamAssassin 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 use maildrop as default for delivery, edit /etc/courier/courierd
and set DEFAULTDELIVERY
to "| /usr/bin/maildrop"
(or wherever your maildrop binary is). Then edit the global filter file /etc/courier/maildroprc
to pipe mail through Spamassassin before delivery:
import USER if ($LOGNAME ne "") { xfilter "/usr/bin/vendor_perl/spamc -u $LOGNAME" } 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:
if(/^X-Spam-Status: YES/) { to "$HOME/Maildir/.Junk/" }
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):
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 preferences.