###################################################################### # repo@beginnerslinux.org # # http://beginnerslinux.org # # This contains many user serviceable parts; you must service them! # ###################################################################### # Things you need to install # # procmail,spamassassin, razor # ############################### PATH=/bin:/usr/bin:/usr/local/bin LINEBUF=4096 MAILDIR=$HOME/mail #you'd better make sure it exists BACKUP=$HOME/backup TRASH=$MAILDIR/junkmail DEFAULT=$MAILDIR/inbox #check this SPAM=$MAILDIR/spam LOGFILE=$HOME/pm.log #review this frequently! VERBOSE = on FGREP=/bin/fgrep FROM=`formail -x From:` REC=`formail -x Received:` TMP=/var/tmp DROPPRIVS=yes ############################### # Make a backup from all mail # # Better safe then sorry :-) # ############################### :0 c ${BACKUP} ######################### # Add some general info # ######################### :0 { :0 fhw | formail -A "X-info-beginnerslinux.org: Use this to flag spam in your mailclient" :0 fhw | formail -A "X-info-beginnerslinux.org: Anti spam by spamassassin and razor" } ############################################################ # First let's start with the whitelist. # # Important because it's the easiest way to accept someone # ############################################################ # copy the original headers # and later add a flag to the new header SUBJ_=`formail -xSubject: \ | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'` # done :0E * ? (echo "$FROM" | $FGREP -i -f $HOME/.procmail/lists/whitelist) { :0 fhw |formail -I"Subject: [WHITELIST] ${SUBJ_}" | formail -A "X-SPAM-INFO: Whitelisted address, so it's safe" LOG="WHITELIST " :0 ${DEFAULT} } ############################################# # Mail from mailinglists we want to recieve # ############################################# # Suse mailinglist # #################### SUBJ_=`formail -xSubject: \ | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'` :0 * ^From.*l4l { :0 fhw |formail -I"Subject: [SUSE] ${SUBJ_}" | formail -A "X-SPAM-INFO: Suse mailinglist" LOG="SUSE " :0 ${DEFAULT} } ################### # Tor mailinglist # ################### SUBJ_=`formail -xSubject: \ | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'` :0 * ^TOor-talk@freehaven.net { :0 fhw |formail -I"Subject: [TOR] ${SUBJ_}" | formail -A "X-SPAM-INFO: Tor mailinglist" LOG="Tor mailinglist " :0 ${DEFAULT} } :0 * ^TOor-talk-outgoing@seul.org { :0 fhw |formail -I"Subject: [TOR] ${SUBJ_}" | formail -A "X-SPAM-INFO: Tor mailinglist" LOG="Tor mailinglist " :0 ${DEFAULT} } ##################### # Linux mailinglist # ##################### SUBJ_=`formail -xSubject: \ | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'` :0 * ^linux@vger.kernel.org { :0 fhw |formail -I"Subject: [LINUX] ${SUBJ_}" | formail -A "X-SPAM-INFO: Linux mailinglist" LOG="Linux mailinglist " :0 ${DEFAULT} } ######################################################### # Lets get seriuous now .... # # First test by sending possible SPAM/VIRUS to ${SPAM} # # If everything works ok replace ${SPAM} by /dev/null # # Also take a look at the logfile (mailstat pmlog) # # to see if everything you block is # # and you will never see the SPAM again # ######################################################### ############################################### # Feed every mail to spamassassin # # and if concidered as SPAM, sent tu junkmail # ############################################### SUBJ_=`formail -xSubject: \ | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'` :0 fw | /usr/bin/spamc :0 * ^X-Spam-Level: \*\*\* * ^X-Spam-Status: Yes { :0 fhw | formail -A "X-SPAM-INFO: BLOCKED BY SPAMASSASSIN" |formail -I"Subject: [SPAM] ${SUBJ_}" LOG="SPAMASSASSIN " :0 ${SPAM} } ################################################# # all the rest we deliver, and give the OK flag # ################################################# SUBJ_=`formail -xSubject: \ | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'` :0 { :0 fhw |formail -I"Subject: [OK] ${SUBJ_}" | formail -A "X-SPAM-INFO: OK" :0 fhw | formail -A "X-SPAM-RULE: OK" LOG="OK " :0 ${DEFAULT} } ########################################### # So, you should be having less SPAM now # # enjoy # ###########################################