# -*- sh -*- # Please check if all the paths in PATH are reachable, remove the ones that # are not. PATH=$HOME/bin:/usr/bin:/bin:/usr/local/bin:. MAILDIR=$HOME/Mail # You'd better make sure it exists LOGFILE=$MAILDIR/procmaillog LOCKFILE=$HOME/.lockmail SHELL=/bin/bash FORMAIL=/usr/bin/formail # Order matters, up until at least the duplicate catching clause. # Pure newline; typical usage if you want to write # Something directly to procmail's active logfile: # # LOG = "$NL message $NL" NL = " " :0 * ^Subject:\/.* { SUBJECT = $MATCH } # Catch duplicates. I got this from some forgotten webpage... MID_CACHE_LEN = 8192 MID_CACHE_FILE = $MAILDIR/msgid.cache MID_CACHE_LOCK = $MAILDIR/msgid.cache$LOCKEXT LOCKFILE = $MID_CACHE_LOCK # IF the message has a message-id header # AND formail -D is successful (exit status=0) # THEN # log a message to the procmail log # sink the message :0 * ^Message-Id: * ? $FORMAIL -D $MID_CACHE_LEN $MID_CACHE_FILE { LOG="dupecheck: discarded message, $SUBJECT $NL" :0 # Store duplicates, notice no lock! duplicates } LOCKFILE # Release lock by killing variable # Colloquial stuff... :0 w: * ^Subject: .*olloquium.* | /users/rreid/bin/collofilt >> $MAILDIR/colloquia :0 w: * ^TO * ^Subject: .*ELF.* | /users/rreid/bin/collofilt >> $MAILDIR/colloquia # Sort away mailing lists that should *not* go straight in the main inbox. # $LIST idea for handling a lot of different lists at once from David Champion # and David W. Tamkin. LISTS = "(casca|drao|HIAlights|NRCEveryone)" :0 * $ ^TO_()\/$LISTS * $ LISTS ?? ()\/$\MATCH { LIST=$MATCH } :0 * LIST ?? . { # List mail that goes to its own box doesn't need [LIST] in its Subject: :0 f | $FORMAIL -i "Subject: `echo $SUBJECT | sed -e \"s/\[${LIST}[^]]*\] *//i\"`" -i "X-Label: ${LIST}" # Dump unwanted threads by Subject: :0: * ? $FORMAIL -x Subject: | grep -isF -f ~/.mutt/killfiles/${LIST} dumpedthreads # Dump unwanted subthreads by message ID: :0: * ? $FORMAIL -x References: | grep -isF -f ~/.mutt/killfiles/msgids/${LIST} dumpedthreads # Send it to a list. :0: $LIST } # Make freshmeat manageable... # Doesn't work on polaris because it doesn't find BerkeleyDB.pm. #:0 w #* ^Subject:.\[fm-news\].Newsletter.* #* !^X-Loop:.*whatsnewfm #| /users/rreid/bin/whatsnewfm.pl :0 w * ^Subject:.\[fm-news\].Newsletter.* * ^X-Loop:.*whatsnewfm | /users/rreid/bin/wnfmsplit >> /users/rreid/mail/meat # Trim whatsnewfm's update subjects. :0 w: * ^Subject: whatsnewfm.pl: Update:.* * ^X-Loop:.*whatsnewfm | sed -e 's/^\(Subject: \)whatsnewfm.pl: Update: \(.*\)/\1\2 update/' >> $MAILDIR/meat :0h: * ^X-Loop:.*whatsnewfm meat # Shuffle off known frequent perpetrators of boring email. :0w: * ? $FORMAIL -x"From" -x"From:" -x"Sender:" -x"Reply-To:" -x"Return-Path:" \ | /bin/grep -isF -f $MAILDIR/boring.list boring # Test if the email's sender is a V.I.P.. If so, don't frisk it! # Warning! egrep is a CPU hog! :0w: * ? $FORMAIL -x"From" -x"From:" -x"Sender:" -x"Reply-To:" -x"Return-Path:" \ | /bin/grep -isF -f $MAILDIR/good.list /var/spool/mail/rreid # Test if the email's sender is blacklisted; if so, send it to $CRAPFILE :0 * ? $FORMAIL -x"From" -x"From :" -x"Sender:" -x"Reply-To:" -x"Return-Path:" \ -x"To:" | /bin/grep -isF -f $MAILDIR/spammers.list { :0fwh | sed -e 's/^\(Subject: \)/\1BLACKLISTED! /' :0: $CRAPFILE } ## Check with Vipul's Razor. #:0 Wc #| razor-check #:0 faw: #| sed -e 's/^\(Subject: \)/\1Razored! /' #:0fw #| spamassassin -P #| sed -e 's/^\(Subject: \)/\1Razored! /' >> $CRAPFILE # Fsck Micro$oft! # Their hotmail ads seem to end in

spam
# Getting rid of the ads also makes them less spammish before their trip # through spamassassin. Do NOT do this before razoring! #:0 fwb #* ^From .*@hotmail\..* #| sed -e 's/<\/div>

.*
<\/html>/<\/div><\/html>/' ## I don't want spam to go through w3m. #:0 fwh #* ^X-Spam-Flag: YES #* ^Content-Type:.*text/html.* #| $FORMAIL -I Content-Type: #CPRE=`cat | grep '^Content preview' | cut -c 18-42 | sed 's/^/\'/' |sed 's/$/\'/'` #* ^Content preview: .{,24} #$CRAPFILE #:0 #* ^X-Spam-Flag: YES #{ # CPRE=`cat | grep '^Content preview' | head -1 |cut -c 18-42|sed 's/%/S5/;s/This message is in MIME/MIME/'` # # :0fhw # | sed -e "s%^\(Subject:\)%\1 ${CPRE} #Was:%" ## >> $CRAPFILE # :0: # $CRAPFILE #} # snag the To: and From: headers #TO=`$FORMAIL -zx To:` #CC=`$FORMAIL -zx Cc:` #FROM=`$FORMAIL -zX From: | $FORMAIL -zrx To:` :0: * ^TOreid\+junk@ | sed -e 's/^\(Subject: \)/\1JUNK! /' >> $SPAMFILE # This address seems to attract a lot of spam. #:0: #* ^TOda@astro\.utoronto\.ca #| sed -e 's/^\(Subject: \)/\1DA! /' >> $SPAMFILE # Killing header and footer ads # if you know that the header is X lines long [let's say 5 for this example] # and that the first line of the footer contains some string or pattern that # will not occur in the significant part of the post, # #:0 fbwi # * conditions # | sed -ne 1,5d -e '/pattern/q' -e p #If you recognize the end by the last line that you want to keep instead of the #first line that you want to delete, omit the n option and the p instruction: # #| sed -e 1,5d -e '/pattern/q' #Finally, if the only reliable way to spot the footer is by reaching so many #lines from the end (because any search pattern might occur in the real text as #well), we can score as you've been doing to get the number of the last #significant line. Let's say the footer is three lines long; because ^.*$ #always counts one line too many (long story), we subtract four instead of #three: #:0 fbwi # * conditions # * 1^1 B ?? ^.*$ # * -4^0 # | sed -e 1,5d -e "$="q