--On September 10, 2015 at 7:37:09 AM +0100 Robert Chalmers
<[email protected]> wrote:
I’m currently running postscreen, and am wondering how I would add
spamassassin to the main.cf configuration, or are they mutually exclusive?
After reading all the answers (I confess I was amazed by some of them), I
can assure you that you can run the two together. I have been for years.
You don't add spamassassin filtering to main.cf, however. You add it to
master.cf.
Here's the relevant sections in my master.cf, but you need to read the
FILTER_README docs and understand them before implementing this:
DO NOT JUST COPY THIS STUFF WITHOUT READING THE DOCS:
# grep filter /usr/local/etc/postfix/master.cf
smtp inet n - n - - smtpd -o
content_filter=filter:dummyr
filter unix - n n - 10 pipe
flags=Rq user=filter argv=/usr/local/bin/filter.sh -f ${sender} --
${recipient}
smtpd pass - - n - - smtpd -o
content_filter=filter:dummy
If you want to run mail through spamd, you would use something like this:
#smtp inet n - - - - smtpd
# -o content_filter=spamassassin
#spamassassin unix - n n - - pipe
# user=spamd argv=/usr/local/bin/spamc -f -e
# /usr/sbin/sendmail -oi -f ${sender} ${recipient}n
The filter script is in the FILTER_README doc. Read it carefully.
You can either feed mail directly to the spamassassin daemon, spamd, or fun
it through a filter script that calls spamassassin for each individual
email. I've tried both, but I use the filter script because it allows me
to write mail to a directory and then sort through it for any legitimate
mail. And frankly, there is very little, if any, legitimate mail in there.
This is a very small mail domain with only two recipients. The owners
don't want to see spam at all, so I am very aggressive. I also send
anything lower than 5 to myself so I can screen it before they see it.
Here's my filter script, which is essentially a ripoff of Weitse's script:
#!/bin/sh
# Simple shell-based filter. It is meant to be invoked as follows:
# /path/to/script -f sender recipients...
# Localize these.
INSPECT_DIR=/usr/local/filter
SPAMDIR=/var/spool/spam
SENDMAIL="/usr/sbin/sendmail -i"
SPAMASSASSIN=/usr/local/bin/spamassassin
SPAMLIMIT=5
SPAMCK=4
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
# Start processing.
cd $INSPECT_DIR || {
echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15
cat | $SPAMASSASSIN -x > out.$$ || \
{ echo Cannot save mail to file; exit $EX_TEMPFAIL; }
if egrep -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < out.$$
then
mv out.$$ $SPAMDIR
elif egrep -q "^X-Spam-Level: \*{$SPAMCK,}" < out.$$
then
$SENDMAIL geek < out.$$
else
$SENDMAIL "$@" < out.$$
fi
trap "rm -f out.$$" 0 1 2 3 15
exit $?
Paul Schmehl ([email protected])
Independent Researcher