# # Kai Puolamäki's (example) procmail recipe file # (a.k.a. $HOME/.procmailrc) # Last modified 1999-11-30 # # Most parts stolen from somewhere, for example the original version of # the mailing list processing was taken from Lars Wirzenius. # # Remember to (double-)check the variables and change all email-addresses! # Note: You may want to edit the lists section, if some lists don't get # correctly caught by the automated system. # # You can disable the filter by renaming your .forward file to something # else, e.g.: mv $HOME/.forward $HOME/forward (at least in systems using # sendmail) # # This filter can co-operate with Spam Bouncer. In its default # configuration it is designed to be as easy to use, simple, # effective and maintenance free, etc. etc., as possible. # # See my web page for further info on how to apply this filter: # http://www.iki.fi/kaip/mail/filter.html # It contains for example info on how to update your whitelist as you send # mail, without you even knowing about it. ############################################################################ # # CONFIGURATION begins # SHELL=/usr/bin/ksh # point to your copy of ksh SENDMAIL=/usr/lib/sendmail # your copy of sendmail (for SB) MAILDIR=$HOME/Mail # hopefully this directory exists LOGFILE=$MAILDIR/LOG # the logfile FORMAIL=$HOME/bin/formail # where is formail? GREP=/usr/local/contrib/bin/gfgrep # where is fgrep? ALTFROM=puolamak+auto@pcu.helsinki.fi.CHANGETHIS # alternate "From" line for autoreplies # (for SB) NOLOOP=$ALTFROM # leave as is (for SB) ADMINFOLDER=$DEFAULT # mail bounces, other administrivia SPAMFOLDER=$DEFAULT # for definite spam BLOCKFOLDER=$DEFAULT # for suspicious mail BULKFOLDER=$DEFAULT # for bulk mail which appears legitimate WHITELIST=$HOME/.procmail/whitelist # mail from these passes spam filtering BLACKLIST=$HOME/.procmail/blacklist # I don't wan't to have mail from these BLACKLISTFOLDER=/dev/null # where to put blackisted mail LOGABSTRACT=all # log log log... # # CONFIGURATION ends # ############################################################################ # # PRELIMINARY PROCESSING begins # # backup mail to $MAILDIR/backup (make sure this directory exists) :0 c backup # store only 100 most recent messages (commented out) #:0 ic #| cd $MAILDIR/backup && rm -f dummy `ls -t msg.* | sed -e 1,100d` # This recipe is most efficiently implemented as a crontab job. # Edit your crontab file by "crontab -e" and add something like # 39 3 * * * cd $HOME/Mail/backup && rm -f dummy `ls -t msg.* | sed -e 1,100d` # nuke duplicate messages (e.g. mail sent both to mailing list and your # personal address) :0 Wh: msgid.lock | $FORMAIL -D 8192 msgid.cache # regenerate "From" lines to make sure they are valid :0 fhw | $FORMAIL -I "From " -a "From " # Count the number of lines, if necessary :0 * ! ^Lines: { # Count number of lines :0B * 1^1 ^.*$ { } LINES = $= # Add Lines: header :0 fhw | formail -a "Lines: $LINES" } # send bounced mail and mail from admin accounts to its own folder :0: * (^FROM_MAILER|\ ^From.*[^0-9A-Za-z]abuse@|\ ^From.*[^0-9a-zA-Z]spam@) | $FORMAIL -A"X-Sorted: Admin" >>$ADMINFOLDER # kill mail from people listed in blacklist (I don't need this, but maybe # you do) #:0: #* ? test -f ${BLACKLIST} && ( ${FORMAIL} -zxFrom: | $GREP -i -f ${BLACKLIST} ) #| $FORMAIL -A"X-Sorted: Blacklist" >>$BLACKLISTFOLDER # # PRELIMINARY PROCESSING ends # ############################################################################ # # MAILING LISTS begins # # # Put all lists that you don't want to get caught by automagical # section here. # # Join EuroCAUCE at http://www.euro.cauce.org/ :) :0: * ^Sender: owner-discussion@lists\.euro\.cauce\.org | $FORMAIL -A"X-Sorted: List; EuroCAUCE" >>ecauce # MAILING LISTS: AUTOMAGICAL SECTION begins (no need to edit) # # try to deduce name of mailing list (and thus its folder) from headers :0: * ^X-mailing-list: <\/[^@/]* | $FORMAIL -A"X-Sorted: List; ${MATCH}" >>$MATCH :0: * ^Delivered-To: mailing list \/[^@/]* | $FORMAIL -A"X-Sorted: List; ${MATCH}" >>$MATCH :0: * ^Sender: owner-\/[^@/]* | $FORMAIL -A"X-Sorted: List; ${MATCH}" >>$MATCH # # MAILING LISTS: AUTOMAGICAL SECTION ends # # # Lists that don't get caught by automagicy (...or why doesn't # everyone use Majordomo?) # # If you are interested: http://www.tky.hut.fi/%7Eshut/ :0: * ^TO_shut_jasenet@.* | $FORMAIL -A"X-Sorted: List; SHUT jasenet" >>$DEFAULT # # MAILING LISTS ends # ############################################################################ # # SPAM FILTERING begins # # mail from those in my whitelist (always pass) :0: * ? test -f ${WHITELIST} && (${FORMAIL} -zxFrom: -zxReply-To: | $GREP -i -f ${WHITELIST}) | $FORMAIL -A"X-Sorted: Whitelist" >>$DEFAULT # One could put here e.g. SpamBouncer: http://www.hrweb.org/spambouncer/ # It can be used to classify spam according to the recipients. Be sure # to read the instructions carefully, though. # NOBOUNCE=$WHITELIST # INCLUDERC=$HOME/.procmail/sb.rc # Really stupid test that does not really catch anything. (Use Spam # Bouncer if you want to classify spam with procmail.) :0: * ^Subject: AD(V?): | $FORMAIL -A"X-Sorted: Blocked" >>$BLOCKFOLDER # mail to recognizable email address of mine # This is an effective test, since usually spammers don't put # your email-address to the headers. :0: * ^(To:|Cc:).*(kpuolama[^+].*|\ puolamak[^+].*|\ puolamaki[^+].*|\ kaip@iki\.fi) | $FORMAIL -A"X-Sorted: Default">>$DEFAULT # Mail not addressed to me goes to the bulk folder. This is where most # of the spam ends up (in default configuration). :0 E: | $FORMAIL -A"X-Sorted: Bulk" >>$BULKFOLDER # # SPAM FILTERING ends # ############################################################################ # done :)