Computerglitch

An ongoing adventure

Spamassassin and Sendmail on OpenBSD

This tip shows how to setup Sendmail with Spamassassin on OpenBSD 3.9


First install Spamassassin:

# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make install clean

Next install Procmail:

# cd /usr/ports/mail/procmail
# make install clean

Now configure Sendmail to work with Spamassassin:

# cd /usr/share/sendmail/cf
# cp openbsd-proto.mc openbsd-proto.mc.bak

Edit openbsd-proto.mc with your favorite editor adding/removing the following:

remove: MAILER(local)
add: FEATURE(local_procmail)
add: MAILER(procmail)dnl

Next backup your current sendmail configuration, make and install the new sendmail configuration:

# cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf.bak
# cd /usr/share/sendmail/cf
# m4 ../m4/cf.m4 openbsd-proto.mc > /etc/mail/sendmail.cf

Create the file /etc/procmailrc and add the following to it:

# vi /etc/procmailrc

DROPPRIVS=yes

:0fw
| spamc

Now add the following line to /etc/rc.local to start spamd at startup

# vi /etc/rc.local

echo -n “spamd”; /usr/local/bin/spamd &

Refer to tip 5 for setting sendmail to send/recieve email


Restart the server

# halt

Finally test your installation of Spamassassin with the following command:

# spamassassin -D < /usr/local/share/doc/SpamAssassin/sample-spam.txt

Some of my personal configuration.
Since I don’t like spam coming to my clients at all, my /etc/procmailrc is as follows:

DROPPRIVS=yes


:0fw
| spamc


:0
* ˆX-Spam-Status: YES
* ˆX-Spam-Level: ******
/var/spool/spam/


This tells procmail to put messages marked as spam with a level higher than 6 to /var/spool/spam which is world writable.


For more information see the Spamassassin Wiki: http://wiki.apache.org/spamassassin/

Comments