User Tools

Site Tools


tutorials_dotfiles_.procmailrc_slugmax
dotfile
# Change these variables to suit your installation
# Note this assumes an mbox-style setup on the SDF cluster
# It will not work on the MetaArray
MAILDIR=$HOME/Mail
LOGFILE=$HOME/.procmail/procmail.log
PATH=/usr/pkg/bin:/bin:/usr/bin
EOL="
"
 
# The white and blacklists list email addresses, one per line
WHITELIST=$MAILDIR/.whitelist
BLACKLIST=$MAILDIR/.blacklist
 
# Grab the from address of this mail
FROM=`formail -c -x 'From:'|sed -e 's/.*<\(.*@[^>]*\)>.*/\1/'`
 
#Check the from address against our blacklist first
LOG="Checking sender \"$FROM\" against blacklist$EOL"
 
# Send blacklisted email to the junk folder.
# Alternately, change 'junk' to /dev/null to discard
:0 hb:
* ? grep -i -F -e "$FROM" $BLACKLIST >/dev/null
junk
 
# Check our whitelist next
LOG="Checking sender \"$FROM\" against whitelist$EOL"
 
# Send whitelisted mail to the inbox
:0 hb:
* ? grep -i -F -e "$FROM" $WHITELIST >/dev/null
inbox
 
#Check the DNSRBL only if the white/blackists have not matched
LOG="Not in whitelist, now checking DNSRBL$EOL"
 
# The multiple greps filter the headers so that we are left with the
# originating mail server. The perl snippet grabs the IP address of
# the originating mail server from the header line and checks it with
# rblcheck Add your own RBL servers by appending multiple '-s' options
SPAMFLAG=`formail -zc -XReceived | grep 'by mx.sdf.org' | grep -v 'from mx.sdf.org' | perl -nle 'if (/^Received: from.+\[(\d+\.\d+\.\d+\.\d+)\].+$/ && (qx(rblcheck -s cbl.abuseat.org -s bl.spamcop.net $1) =~ /is listed/gms)) {print "$1 flagged as SPAM";} else {print "$1 passed";}'`
LOG="RBL check result: $SPAMFLAG$EOL"
 
# Send RBL-tagged spam to the junk folder
:0 :
* SPAMFLAG ?? SPAM
junk
 
# All else goes to ~/Mail/inbox
:0 :
inbox
tutorials_dotfiles_.procmailrc_slugmax.txt · Last modified: 2021/03/24 00:41 by hc9