# VERBOSE = on # ---------------------------------------------------------- # /home/mengwong/.procmailrc-lists # called by anyone who wants to deal with lists # # messages go to the ~/Mail/Lists directory # to be read using /usr/local/bin/readlists or this sh script: # for i in ~/Mail/Lists/*; do elm -zf $i; done # note that this will Do The Wrong Thing with lists whose # real names start with [^a-zA-Z] due to the nature of the # ^TO expression. # # EXTERNAL VARIABLES # MAILDIR should be $HOME/Mail # LISTS should look like "edupage|bugtraq|blahblah" # LISTLOGFILE (optional) -- append the listname to this file # LISTGREP (optional) -- if message contains this regexp in body or subject, # send to main mailbox as well # LISTGREPTO (optional) -- if message contains this regexp in to, # send to main mailbox as well # SPECIALLIST -- helenfans # SPECIALTEXT -- food|lunch|dinner|now|movie # ---------------------------------------------------------- # ---------------------------------------------------------- # idiot filter # ---------------------------------------------------------- :0: * B ?? < 100 * ((un)?subscribe|remove|signoff) * ! $ (^TO|^From:.*)(pobox.com|$\LOGNAME) Lists/idiots # ---------------------------------------------------------- # main list separation stuff # ---------------------------------------------------------- :0 * 1^0 $ ^TO\\/($LISTS)(@|%) * 1^0 $ ^Sender: \\/(owner-)($LISTS)(-owner)(@|%) { # messages that are To the list and CC to me will arrive # twice. the first instance should go to my mailbox. # the second (if any) should go to the list dir. now, # how do we do this ... hm. first we flag both cases # as CONTINUE, then we weed out the First Instances by # checking if they've appeared in the idcache yet. # the ones which have will be flagged out. CONTINUE = yes :0 * $ ^TO$\LOGNAME(@|%) * ! ? formail -D 8192 $HOME/.idcache-listsarchive { CONTINUE # undefine CONTINUE for statement below LISTGREP # no need to bother with checking for special contents. } } :0 * CONTINUE ?? yes { CONTINUE LISTDIR = Lists # just in case the To: line contains lists to which I'm # multiply subscribed, we'll check the Sender: line to # see which mailbox this message gets to go to. also, we # have to beware of shellmetas. OLDMATCH = $MATCH SENDER = `formail -zx Sender:` :0 * SENDER ?? [^A-Za-z0-9]?\/[A-Za-z0-9_-]+(@|%) { SENDER = $MATCH # clean out shell metacharacters for the echo statement later SED_ALPHA = "&|<>~;?*'[" SED_BETA = "" SED_RIGHT = $SENDER SED_CONTINUE = "1" SED_RCFILE = $RC_sed INCLUDERC = $SED_RCFILE SENDER = $SED_RIGHT MATCH = $OLDMATCH :0 * $ SENDER ?? (owner-)?($LISTS)(-owner)? { MATCH=`echo $SENDER|sed -e 's/-owner.*//; s/.*owner-//; s/@.*/@/; s/%.*/@/;'` } } # in any case, MATCH now contains "listname@". sed to # lowercase, wipe out / and @ symbols ... LISTNAME =`echo $MATCH | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/; s/%//; s/@//; s/\///;'` :0w: # undigestify digests * ^TOdigest * ! ^TO(splinters|undercover)-digest |formail -ds >> $LISTDIR/$LISTNAME # are we interested in a special string? # let's see if this message to a mailing list contains that string. # start by assuming no. CCTOUSER = no MATCH :0B # it could be in the subject or the body * LISTGREP ?? . * -1^0 * 2^0 $ H ?? ^Subject: .*(\\<|^)\\/($LISTGREP)(\\>|\$) * -2^0 $ H ?? ^Subject: .*($LISTGREPIGNORE) * 2^0 $ (\\<|^)\\/($LISTGREP)(\\>|\$) * -2^0 $ ($LISTGREPIGNORE) { CCTOUSER = yes MATCHEDSTUFF = $MATCH } :0 # match TO * LISTGREPTO ?? . * -1^0 * 2^0 $ List-ID: \/($LISTGREPTO) * 2^0 $ ^TO\\/($LISTGREPTO) * -2^0 $ H ?? ^Subject: .*($LISTGREPIGNORE) * -2^0 $ B ?? ($LISTGREPIGNORE) { CCTOUSER = yes MATCHEDSTUFF = $MATCH } :0 # and we want to grep helenfans mail for food notices. sigh. * SPECIALLIST ?? . * SPECIALTEXT ?? . * $ ^TO($SPECIALLIST) * -1^0 * -2^0 ^Subject:.*[listmail * 2^0 $ ^Subject:.*(\\<|^)\\/($SPECIALTEXT)(\\>|\$) * 2^0 $ B ?? (\\<|^)\\/($SPECIALTEXT)(\\>|\$) { CCTOUSER = yes MATCHEDSTUFF = $MATCH } :0 * CCTOUSER ?? yes * MATCHEDSTUFF ?? . { # at this point MATCHEDSTUFF might have a trailing \>. # (might because it also might just be $) :0 * MATCHEDSTUFF ?? ^\/[a-zA-Z0-9_-]+ { MATCHEDSTUFF = $MATCH } :0fhw * ! ^Subject: .*[listmail * ^Subject: \/.* |formail -i "Subject: [listmail $LISTNAME $MATCHEDSTUFF] $MATCH" :0fhw |formail -I "X-Procmail-Says: list message contains \"$MATCHEDSTUFF\" so CC'ed to user" } :0 fbw * LISTAUTOSIG ?? . * $ LISTNAME ?? $LISTAUTOSIG * ^From: \/.* | echo "------------------------------------------------------------"; \ echo "AutoSig: $MATCH"; \ echo "------------------------------------------------------------"; \ echo; \ cat; \ echo "------------------------------------------------------------"; \ echo "AutoSig: $MATCH" :0 * LISTSTOSAVE ?? . * $ LISTNAME ?? $LISTSTOSAVE { ARCHIVECC = yes ARCHIVEDIR = Archives SAVETOLISTS = no ARCHIVENAME = $LISTNAME INCLUDERC = $RC_archive } :0c: $LISTDIR/$LISTNAME PREVIOUSLOGABSTRACT = $LOGABSTRACT LOGABSTRACT = no :0 * ! CCTOUSER ?? yes /dev/null LOGABSTRACT = $PREVIOUSLOGABSTRACT }