#!/bin/sh # ----------------------------------------------------------------- # File: spamchk # # Author Mike O'Brien # # Report Bugs to mike@mobrien.com # # Purpose: SPAMASSASIN shell-based filter # # Location: /etc/postfix # # Usage: Call this script from master.cf (Postfix) # # SpamAssassin Config /etc/mail/spamassassin/local.cf # # Whitelist Config in /etc/mail/spamassassin/local.cf # # These are the Postfix master.cf entries #smtp inet n - n - - smtpd # -o content_filter=spamchk:dummy #spamchk unix - n n - 10 pipe # flags=Rq user=filter argv=/etc/postfix/spamchk -f ${sender} -- ${recipient} # # # # Remember to run the following to build the seed bayesian dbs files # sa-learn --spam /home/spamd # sa-learn --ham /home/spamd # ----------------------------------------------------------------- # Variables SENDMAIL="/usr/local/sbin/sendmail -i" EGREP=/usr/bin/egrep # Exit codes from EX_UNAVAILABLE=69 # Number of *'s in X-Spam-level header needed to sideline message: # (Eg. Score of 5.5 = "*****" ) SPAMLIMIT=3 # Clean up when done or when aborting. trap "rm -f /usr/tmp/out.$$" 0 1 2 3 15 # Pipe message to spamc cat | /usr/local/bin/spamc -u filter > /usr/tmp/out.$$ # serious business if $EGREP -q "^X-Spam-Level: \*\*\*" < /usr/tmp/out.$$ #if $EGREP -q "^X-Spam-Level: *{$SPAMLIMIT,}" < /usr/tmp/out.$$ then # $SENDMAIL jnk@yourdomain.com < /usr/tmp/out.$$ rm -f /usr/tmp/out.$$ else $SENDMAIL "$@" < /usr/tmp/out.$$ fi # Postfix returns the exit status of the Postfix sendmail command. exit $?