How to install SpamAssassin on OpenBSD with sendmail

This is a quick writeup of the things I needed to do to install spamassassin on my OpenBSD 3.2 server, which is running sendmail. If you find errors, corrections, or things that I should clarify, please drop me a note.

This howto assumes you've already got perl5 (or later) installed and running. You'll need to be root for at least part of the install.

If you're running OpenBSD 3.1, spamassassin is not part of the ports tree (but its directory is there), and you'll have more headaches to deal with. The quick answer is that you can get it, but you'll have to do a few things manually. I'll list that procedure at the end. And even if you're running 3.2, the spamassassin port won't install everything because the install is different based on what mail-server you're running.

This is based in part on Doug Hunley's StepByStep, but I've changed things to fit with OpenBSD. You might be able to skip the CPAN step (I think most of that will be picked up by the SpamAssassin install), but these are the steps I went through, and it worked out for me.

  1. Install various things from the CPAN (you may have many already installed):
    1. % perl -MCPAN -e shell
    2. cpan> install MD5
    3. cpan> install LWP
    4. cpan> install File::Path
    5. cpan> install File::Spec
    6. cpan> install IPC::Open2
    7. cpan> install Net::SMTP
    8. cpan> install Mail::Internet
    9. cpan> install Digest::SHA1
    10. cpan> install Net::DNS
    11. cpan> install Digest::Nilsimsa
  2. Install procmail:
    1. % cd /usr/ports/mail/procmail
    2. % make
    3. % make install
  3. Install spamassassin: Here's where you'll have to do extra work if you're on 3.1 or before
    1. % cd /usr/ports/mail/p5-Mail-SpamAssassin
    2. % make
    3. % make install
  4. Configure:
    1. % cd /usr/share/sendmail/cf
      (or /usr/src/gnu/usr.sbin/sendmail/cf/cf)
    2. Edit your to make the following changes:
      1. add FEATURE(local_procmail)
      2. add MAILER(procmail)dnl
      3. remove MAILER(local)
    3. % make
    4. % cp /etc/mail
    5. create /etc/procmailrc with the following contents:

      | spamc
    6. % echo "/usr/bin/spamd" >> /etc/rc.local
      On versions of OpenBSD after 3.2, this is /usr/local/bin/spamd
    7. And then make any changes you think you need to /etc/mail/spamassassin/
  5. Restart the daemons or just restart your system. You'll need to manually start spamd if you don't restart the system now.

At this point, you should be able to send yourself an email and see it come through successfully. If not, go check /var/log/maillog and see if there's anything useful in there.


On OpenBSD 3.1 or earlier:

You need to do something like the following steps. It'll vary depending on what system you're on. Deleting the CVS/Tag file means that you'll be getting spamassassin from the tip of the ports tree. My experience was that the Makefile was slightly incorrect, but perl could rebuild it just fine.

  1. % cd /usr/ports/mail/p5-Mail-SpamAssassin
  2. % rm CVS/Tag
  3. % cvs -d up
  4. % make
  5. % cd w-p5-Mail-Spam*/Mail-Spam*
  6. % perl
  7. % cd /usr/ports/mail/p5-Mail-SpamAssassin
  8. % make && make install
Copyright 2009, Dave Polaschek. Last updated on Mon, 15 Feb 2010 14:09:35.