ClamSMTP + Bogofilter
smtp inet n - n - - smtpd
-o content_filter=clamsmtp:127.0.0.1:10025
-o receive_override_options=no_address_mappings
# clamsmtp
clamsmtp unix - - n - 16 smtp
-o smtp_send_xforward_command=yes
# injecting back
127.0.0.1:10026 inet n - n - 16 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=check_recipient_access,pcre:$config_directory/
rcpt-bogofilter.pcre,permit_mynetworks,reject
-o mynetworks_style=host
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
bogofilter unix - n n - - pipe
flags=R user=bogofilter argv=/usr/local/etc/bogofilter/postfix-filter.sh -f ${sender} -- ${recipient}
# first match!
#/^spamlover@example\.org$/ OK
/.*/ FILTER bogofilter:
postfix-filter.sh
#!/bin/sh
FILTER=/usr/local/bin/bogofilter
POSTFIX="/usr/local/sbin/sendmail -i"
export BOGOFILTER_DIR=/usr/local/etc/bogofilter
# 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 msg.$$ ; exit $EX_TEMPFAIL" 0 1 2 3 15
# bogofilter -e returns: 0 for OK, nonzero for error
rm -f msg.$$ || exit $EX_TEMPFAIL
$FILTER -p -u -e > msg.$$ || exit $EX_TEMPFAIL
exec <msg.$$ || exit $EX_TEMPFAIL
rm -f msg.$$ # safe, we hold the file descriptor
exec $POSTFIX "$@"
exit $EX_TEMPFAIL