PATH=/bin:/usr/bin:/usr/local/bin:$HOME/bin MAILDIR=$HOME/Maildir DEFAULT=$MAILDIR/ PMDIR=$HOME/.procmail # Logging to keep track of my emails. LOGFILE=$PMDIR/log LOGABSTRACT=all LINEBUF=4096 #VERBOSE=yes # Rewrite PGP emails a little so they come out in a format that mutt will # understand automatically. #:0 #* !^Content-Type: message/ #* !^Content-Type: multipart/ #* !^Content-Type: application/pgp #{ # :0 fBw # * ^-----BEGIN PGP MESSAGE----- # * ^-----END PGP MESSAGE----- # | formail \ # -i "Content-Type: application/pgp; format=text; x-action=encrypt" # # :0 fBw # * ^-----BEGIN PGP SIGNED MESSAGE----- # * ^-----BEGIN PGP SIGNATURE----- # * ^-----END PGP SIGNATURE----- # | formail \ # -i "Content-Type: application/pgp-signed; format=text; x-action=sign" #} # # Count the number of lines, if necessary. (This is rather pointless for # mbox-delievered messages, but it's here just in case I need it.) :0 * ! ^Lines: { # Count number of lines :0B * 1^1 ^.*$ { } LINES = $= # Add Lines: header :0 fhw | formail -a "Lines: $LINES" } # Silly people trying to set their own email status. :0 fhw * ^(X-)?Status: | formail -I Status -I X-Status # Likewise for SpamAssassin. I'll do my own checks, thanks. :0 fw * ^X-Spam-(Status|Level|Score|Report): | spamassassin -d # In a similar vein, I made this header up, but might as well have a # recipe to remove it for paranoia's sake. :0 fhw * ^X-List-Classify: | formail -I X-List-Classify # Useless use of Reply-To: :0 fhw * ^Reply-To: \/.+ * $ ^From:.*$MATCH | formail -I Reply-To # No filtering on wedding email, just in case. :0 * ^TO_wedding@aperiodic.net .wedding/ # And now the mailing list rules. # Per-list tidying. :0 fhw * ^List-Id: tinyfugue | sed -e "s/^\\(Subject:.*\\)\\[TF\\]\\( \\)*/\\1/I" :0 fhw * ^List-Id: PDF Rangers | sed -e "s/^\\(Subject:.*\\)\\[PDF Rangers\\]\\( \\)*/\\1/I" # Dropping list mail into mailboxes. # To avoid duplication of recipes, I have the various types of mailing # lists set an X-List-Classify header and then have a single ruleset that # triggers on that header. # Note that this allows the creation or alteration of near-arbitrary files on # your computer. Take care with the data. I disallow dot (.) and forward # slash (/) from the list names for this reason. # most lists - RFC2919 and some variants. :0 fhw * ^((List-Id|X-(Mailing-)?List):(.*[<]\/[^>@\.\/]*)) | formail -I "X-List-Classify: $MATCH" # Majordomo :0 fhw * ^Sender: owner-[^@]+@[^@\+]+ * ^Sender: owner-\/[^@\+\.\/]+ | formail -I "X-List-Classify: $MATCH" # yahoogroups :0 fhw * ^Mailing-List: list \/[^@\.\/]+ | formail -I "X-List-Classify: $MATCH" # ezmlm :0 * ^Mailing-List: contact \/[^@\+\.\/]+ { LISTID=`echo $MATCH | sed -e 's/-help$//'` :0 fhw | formail -I "X-List-Classify: $LISTID" } # Lists that aren't caught by the generic rules. # Technically, the moderator address isn't a list, but I like to treat it as # one. :0 fhw * ^X-eGroups-Moderators: freecyclebaltimore | formail -I "X-List-Classify: owner-freecyclebaltimore" :0 fhw * ^TO_burningass-owner@playadelfuego.org | formail -I "X-List-Classify: owner-burningass" # Grumble, grumble, Mailman 2.1.4, not RFC2919 compliant... :0 fhw * ^List-Id: void.slab.org | formail -I "X-List-Classify: void" # calefaction, too. :0 fhw * ^List-id: calefaction\. | formail -I "X-List-Classify: calefaction" # stumpwm-devel, too. :0 fhw * ^List-Id: stumpwm-devel\. | formail -I "X-List-Classify: stumpwm-devel" :0 fhw * ^Subject: (Best of )?Internet Oracularities | formail -I "X-List-Classify: oracle" :0 fhw * ^Sender: risks-owner | formail -I "X-List-Classify: risks" :0 fhw * ^Subject: Physics News Update | formail -I "X-List-Classify: physnews" :0 fhw * ^From: OK Go Newsletter | formail -I "X-List-Classify: okgo" :0 fhw * ^Subject: THIS is TRUE | formail -I "X-List-Classify: thisistrue :0 fhw * ^To: fire-conclave-announce | formail -I "X-List-Classify: fire-conclave" :0 fhw * ^Sender: midrange-nontech-bounces | formail -I "X-List-Classify: midrange-nontech" :0 fhw * ^Sender: pasdoc-main-admin | formail -I "X-List-Classify: pasdoc-main" :0 fhw * ^reply-to: otakon-staff-discussion@otakon.org | formail -I "X-List-Classify: otakon-staff" :0 fhw * ^List-Id: <[a-zA-Z0-9_].alerts.google.com> | formail -I "X-List-Classify: google-alerts" :0 fhw * ^X-Mailing-List: ota-staff-info | formail -I "X-List-Classify: ota-staff-info" :0 fhw * ^List-Id:.*[<]talk.openstreetmap.org[>] | formail -I "X-List-Classify: osm-talk" :0 fhw * ^List-Id:.*[<]announce.openstreetmap.org[>] | formail -I "X-List-Classify: osm-announce" :0 fhw * ^List-Id:.*[<]newbies.openstreetmap.org[>] | formail -I "X-List-Classify: osm-newbies" :0 fhw * ^List-Id:.*[<]talk-us.openstreetmap.org[>] | formail -I "X-List-Classify: osm-talk-us" :0 fhw * ^List-Id:.*[<]tagging.openstreetmap.org[>] | formail -I "X-List-Classify: osm-tagging" :0 fhw * ^List-Id:.*[<]dev.openstreetmap.org[>] | formail -I "X-List-Classify: osm-dev" :0 fhw * ^List-Id:.*[<]talk-transit.openstreetmap.org[>] | formail -I "X-List-Classify: osm-talk-transit" # Fix some list names. :0 fhw * ^X-List-Classify: baltolug_baltinet | formail -I "X-List-Classify: baltolug" :0 fhw * ^X-List-Classify: baltwash-burning-playadelfuego | formail -I "X-List-Classify: baltwash-burning" :0 fhw * ^X-List-Classify: burningass-playadelfuego | formail -I "X-List-Classify: burningass" :0 fhw * ^X-List-Classify: greeters-playadelfuego | formail -I "X-List-Classify: greeters" :0 fhw * ^X-List-Classify: rangers-playadelfuego | formail -I "X-List-Classify: rangers" :0 fhw * ^X-List-Classify: technical-playadelfuego | formail -I "X-List-Classify: technical" :0 fhw * ^X-List-Classify: otakon-staff | sed -e "s/^\\(Subject:.*\\)\\[Otakon Staff\\] */\\1/I" # Now actually do something with the email. :0 * ^X-List-Classify: \/[0-9a-z-]+ { LIST=$MATCH # First off, junk any duplicate emails, but only if they've been seen # before. :0 Wh: $MAILDIR/msgids/$LIST.lock | formail -D 8192 $MAILDIR/msgids/$LIST.cache :0 fhw | formail -I X-List-Classify # List management emails should go in my inbox. :0 * ^Message-ID: .tribe/ :0 * ^From: .*member@orkut.com> * ^X-Mailer: aspNetEmail .orkut/ :0 * ^From: MTA .mta/ :0 * ^From: .*ay2ewx5x@facebookmail.com> .facebook/ # Get rid of pesky viruses. # Some rules here courtesy of http://www.xs4all.nl/~rsmith/spamblock.html # Filter the W32/KLEZ,W32/Yaha, W32/Sobig.F viruses. :0 HB * ^Content-Type: multipart/(mixed|alternative) * ^Content-Type:.*(audio/x-|application|x-rasmol) * name=.*\.(scr|com|bat|pif|lnk|exe) { LOG="(virus) [KLEZ/YAHA/Sobig.F] " :0 /dev/null } :0 * ^X-MailScanner: Found to be clean { LOG="(virus) [Sobig.F] " :0 /dev/null } # WIN32 programs. This should catch them all, since it detects the # bas64 encoded executable header. :0 B * ^Content-Transfer-Encoding:.*base64 * ^TVqQAAMAAAAEAAAA//8AALg * 4fug4AtAnNIbg { LOG="(virus) [win32 exe] " :0 /dev/null } # SpamAssassin stuff. # First, run the email through SpamAssassin :0 fw | spamc # Note the spam score :0 hc | process_spam_score # Save it if it's really highly scored. # Current best: 82.2 with v3.1.4 :0 * ^X-Spam-Status: Yes, score=\/[0-9-]+ * ? test $MATCH -gt 82 .notable-spam/ # Drop all other spam over score 10. :0 * ^X-Spam-Status: Yes, score=\/[0-9-]+ * ? test $MATCH -gt 10 /dev/null # Keep the rest for double-checking. :0 * ^X-Spam-Status: Yes .spam/ # And run the rest through lbdb to capture email addresses. :0 hc | lbdb-fetchaddr -a