Using SpamAssassin on a Sendmail relay
Using SpamAssassin with Sendmail on a mail relay (i.e. a mail server
that is not the final destination of the email) may be accomplished
through the use of a "milter" plugin or by procmail.
Milter solutions:
1. MIMEdefang
2. milter-spamc
3. spamass-milt
Procmail solutions:
1. How to
Filter All Incoming (and/or Outgoing) Mail with procmail
The following document details the procmail solution on a Solaris 8
system running Sendmail 8.12.11 and SpamAssassin 2.63. Please read the
above link in its entirety before attempting this solution.
Step-by-step instructions
1. Install procmail.
I chose to download and install the procmail package from Sunfreeware.
2. Install Perl 5.8.0.
The version of Perl supplied with Solaris 8 is 5.005_03. Newer versions
of SpamAssassin will not include support for versions of Perl earlier
than 5.6.0.
I chose to download and install the Perl 5.8.0 package from Sunfreeware.
3. Install SpamAssassin and all prerequisites using the CPAN module.
su -
/usr/local/bin/perl -MCPAN -e shell
install Mail::SpamAssassin
4. Configure the Sendmail macro
configuration file.
Add the following lines toward the top of sendmail.mc (below the MAILER
lines):
define(`PROCMAIL_MAILER_ARGS',
`procmail -m $h $g $u')dnl
define(`PROCMAIL_MAILER_FLAGS',
`mSDFMhun')dnl
Add the following to the bottom of sendmail.mc:
MAILER(procmail)dnl
LOCAL_CONFIG
CPprocmail
LOCAL_RULESETS
LOCAL_RULE_0
R$* < @ $=w >
$* $#procmail $@
/etc/mail/procmailrc $: $1<@$2.procmail.>$3
R$* < @ $=w. >
$* $#procmail $@
/etc/mail/procmailrc $: $1<@$2.procmail.>$3
R$* < @ $=R >
$* $#procmail $@
/etc/mail/procmailrc $: $1<@$2.procmail.>$3
R$* < @ $=R. >
$* $#procmail $@
/etc/mail/procmailrc $: $1<@$2.procmail.>$3
R$* < @$* .procmail. >
$*
$1<@$2.>$3 Already filtered, map to
original address
Note: it is essential to use tabs
between $*/$#, $*/$1, and $3/Already in the lines above!
5. Create the site-wide /etc/mail/procmailrc
file. The file must end with:
:0 w
! -oi -f "$@"
Here are the
contents of my /etc/mail/procmailrc
file:
:0fw:spamassassin.lock
* < 256000
| /usr/local/bin/spamc
:0 w
! -oi -f "$@"
6. Configure the site-wide /etc/mail/spamassassin/local.cf
file, if applicable. I chose to add required_hits
10 and report_safe 0
when testing out SpamAssassin on a Sendmail relay.
7. Backup the Sendmail configuration file; build and install the new
Sendmail configuration file.
cp /etc/mail/sendmail.cf
/etc/mail/sendmail.cf.`date +%m.%d.%y`
cd Sendmail_source/cf/cf
su root -c 'PATH=$PATH:/usr/ccs/bin
./Build install-cf'
8. Create a spamd
startup/shutdown script.
cat << SCRIPT >
/etc/init.d/spamd
#!/bin/sh
case \$1 in
'start' )
/usr/local/bin/spamd
-d -u nobody
;;
'stop' )
pkill spamd
;;
*)
echo "usage:
\`basename \$0\` {start|stop}"
esac
SCRIPT
chown root:sys /etc/init.d/spamd
chmod 744 /etc/init.d/spamd
9. Start the SpamAssassin daemon.
/etc/init.d/spamd start
10. Send Sendmail a SIGHUP to reread the new configuration file.
kill -HUP `head -1
/var/run/sendmail.pid`
Back
to brandonhutchinson.com.
Last modified: 10/06/2004