Postfix content_filter (Was: Re: mailing list speed)
David Relson
relson at osagesoftware.com
Tue Oct 8 16:28:57 CEST 2002
Amos,
Below is some information on using bogofilter as a postfix filter. This is
work I did a while back while I was figuring out how to get postfix to work
with a spam filter. I've removed a bit of debugging stuff from the script,
but don't think I've broken it. Let me know how it goes.
David
In /etc/postfix/master.cf:
Add a line after the smtp line, as in:
smtp inet n - n - - smtpd
-o content_filter=filter:
At the end, add the following:
filter unix - n n - - pipe
flags=R user=filter argv=/usr/local/bin/filter.sh -f ${sender} --
${recipient}
For /usr/local/bin/filter.sh, I have:
#!/bin/sh
BOGOFILTER=/usr/local/bin/bogofilter
BOGOFILTER_DIR=/var/spool/filter
SENDMAIL=/usr/lib/sendmail
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
cd $BOGOFILTER_DIR || { echo $BOGOFILTER_DIR does not exist; exit
$EX_TEMPFAIL; }
# Clean up when done or when aborting.
trap "rm -f inp.$$ msg.$$" 0 1 2 3 15
# bogofilter returns: 0 for spam; 1 for non-spam; 2 for I/O or other
errors.
cat | $BOGOFILTER -d /var/lib/bogofilter/ -p > msg.$$
$SENDMAIL "$@" < msg.$$
exit $?
For summay digest subscription: bogofilter-digest-subscribe at aotto.com
More information about the Bogofilter
mailing list