Skip to topic | Skip to bottom
Home
Freebsd
Freebsd.FilterMailWithSpamAssassinViaMilterr1.2 - 22 Nov 2003 - 17:09 - KirkStrausertopic end

Start of topic | Skip to actions



This is an alternative to the instructions at FilterMailWithSpamAssassinAndProcMail.

The general theory is that incoming mail will be piped through a SendMail "milter", or mail filter, before delivery. The milter I recommend has the nice feature that it only processes mail bound for local delivery, and not mail passing through the server as an intermediate hop in a relay chain. That is, if you're running a backup MX for an associate, mail that is eventually bound for delivery at their server will not be processed. This saves resources on your server and gives your associate the ability to not use SpamAssassin if they chose not to.

Advantages:

  • It doesn't require an installation of ProcMail?.
  • It's much simpler than installing and configuring ProcMail?.

Disadvantages:

  • None that I've found.

1. Install SpamAssassin

  • If you have PortInstall? (from the sysutils/portupgrade port):
    portinstall mail/p5-Mail-SpamAssassin
  • Otherwise:
    cd /usr/ports/mail/p5-Mail-SpamAssassin; make install; make clean

2. Install the milter

gcc -L/usr/obj/usr/src/lib/libsm -lsm -lmilter -pthread spamassassin_milter.c -o spamassassin_milter

  • Install it: cp spamassassin_milter /usr/local/sbin
  • Make an rc.d script to run it automatically at boot. I've named mine /usr/local/etc/rc.d/spamassassin_milter.sh.

#!/bin/sh

if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
    echo "$0: Cannot determine the PREFIX" >&2
    exit 1
fi

case "$1" in
start)
        if [ -x ${PREFIX}/sbin/spamassassin_milter ]; then
                ${PREFIX}/sbin/spamassassin_milter -p unix:/var/run/spamassassin_milter.sock &
                echo -n ' spamassassin_milter'
        fi
        ;;
stop)
        killall spamassassin_milter && echo -n ' spamassassin_milter'
        ;;
*)
        echo "Usage: `basename $0` {start|stop}" >&2
        ;;
esac

exit 0

  • Make the rc.d script executable: chmod a+x /usr/local/etc/rc.d/spamassassin_milter.sh
  • Start the milter: /usr/local/etc/rc.d/spamassassin_milter.sh start

3. Configure SendMail

Add this near the end of your LocalSendmailConfiguration:

INPUT_MAIL_FILTER(`SpamAssassinFilter', `S=unix:/var/run/spamassassin_milter.sock')
define(`confMILTER_LOG_LEVEL', 7)

4. Return to FilterMailWithSpamAssassin to finish up.

-- KirkStrauser - 03 Jul 2003


You are here: Freebsd > FilterMailWithSpamAssassinViaMilter

to top

Copyright © 1999-2008 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Subwiki? Send feedback