################################################################ # Here we go.... # # my very own mail-mangler # ################################################################ ################################################################ # Updated to have working URLs and arbitrarily version-bumped # # to 1.2 on the grounds it matched the mutt version. Very # # little beyond URLs and list addresses has changed. # # 2002-03-21. # # # # Further updated to fix broken URLs again in 2005-12-31. # ################################################################ ################################################################ # In the spirit of the net, 90% of this came from other people # # and the remaining 10% might be from me. Most of the 90% # # came from documents by Catherine A. Hampton which no longer # # seem to be online but which I found at # # http://www.spambouncer.org/ long ago, or from # # # # man procmail (overview) # # man procmailrc (writing the procmailrc) # # man procmailex (example recipes) # # man formail (especially for splitting digests) # # # # and .procmailrcs from several friends. Thanks, folks, # # especially to the one who had more patterns which sent # # things to /dev/null than to mailboxes, for showing me # # what true impatience with email was like! # ################################################################ ################################################################ # Procmailrc files have two parts. First you tell it where # # everything lives. Then you tell it the recipes. # ################################################################ ########################################## # Varibiggles and where everything lives # ########################################## ################################################################ # All of these will work quite happily without changing for # # Red Hat Linux 6.0 through to 9 and for Fedora Core versions # # 1 to (at least) 3. They won't necessarily work for other # # flavours without changing paths but I think they are pretty # # standard. # ################################################################ ################################################################ # When first I was using procmail with Exim, I had to change # # details of the "pipe transport" in /etc/exim.conf to # # accomodate procmail. This was in about 1998. I doubt this is # # still necessary (I am now not using Exim, so I don't know), # # but if it is, the Exim docs were pretty clear. # ################################################################ SHELL=/bin/bash # Have to have this one (or whatever your shell is) # Best bet is bash or sh. LINEBUF=4096 # Magic. Apparently it burps on long lines if you don't # put this in. PATH=/bin:/usr/bin:/usr/local/bin # Where procmail looks for stuff. Works for practically # every Linux distro I have seen. VERBOSE=off # Change to 'on' to get _long_ procmail log. # NB: if this is short, I don't want to see long: I get # a one-line summary for every email procmail looks at! MAILDIR=$HOME/Mail # Not where your mail arrives on the machine. Where # procmail will assume all the folders you mention in # your recipes goes. Make sure your email-reading # program also knows about it. (I understand $HOME/Mail # is pretty standard, however.) LOGFILE=$HOME/Mail/procmaillog # I don't think this needs to be in your Mail folder, # but my mail-reader (mutt) is great at different # sorting, so I put the log into the mail directory :) # Note learned through experience: if you leave this file # too long, it will end up with tens of thousands of # messages. Delete it regularly! FORMAIL=/usr/bin/formail # 'formail'. Part of the procmail package. Correct # the path if this isn't where it lives for you. # ('which formail' may well tell you.) SENDMAIL=/usr/sbin/sendmail # As with formail, tells procmail where to look for # sendmail. If sendmail isn't there, mail transfer # might be handled by a different program. Ask # your sysadmin :) If you are your own sysadmin, # then I hope you know. # Subsequent to writing that, I have learned that this # file is provided (with this name) by other MTAs too. ############################ # The recipes - I hope... # ############################ ################################################################ # Nuke the dupes: # # # # No clue how this works. But it's very useful. If you get # # email that is sent simultaneously to you and to two other # # lists, this will nuke two of those so that you only see it # # once. Came from 'man procmail'. # ################################################################ # Nuke duplicate messages :0 Wh: msgid.lock | $FORMAIL -D 8192 msgid.cache ################################################################ # Next two are from a 'Getting started with procmail' doc # # I'm not too sure about how they work, but they look handy... # ################################################################ # Create a backup cache of 200 most recent messages in case of # mistakes (yes, you can change the 200 to 20 or 400 or whatever # you want) :0 c backup :0 ic | cd backup && rm -f dummy `ls -t msg.* | sed -e 1,200d` # Regenerate "From" lines to make sure they are valid :0 fhw | formail -I "From " -a "From " ################################################################ # For testing rules. I picked a subject line that no-one would # # send me and then tried different recipes on the results, and # # then sent myself a whole pile of email about grobblefruit, # # with different recipes here, to see what happened when I # # tried different headers and so on. # ################################################################ :0: * ^Subject: Test grobblefruit IN.testing ################################################################ # Really important in these spammy days. This assumes that # # spamassassin is running and tagging email as spam rather # # than deleting it for you. The recipe dumps all tagged email # # into a spam folder. If you are brave, you can subsequently # # substitute the filename /dev/null for the filename IN.spam # # # # Oh, and spamc is the client to run when there are lots of # # users on the same system. # ################################################################ :0fw | spamc :0: * ^X-Spam-Status: Yes IN.caughtspam ################################################################ # Mailing lists # # # # I think this is the thing that most people who finally get # # procmail want to know about: how to get different messages # # from different mailing lists into different folders. This is # # where all that MAILDIR stuff comes from. All the folders I # # name in here are all created off whatever directory I filled # # in as the MAILDIR at the start. And no, they don't suddenly # # appear the instant you edit this file. They only appear when # # procmail finds mail that should go in them. # # # # You can have more than one recipe sending email into the # # same folder, btw, yes. # # # # General useful (?) comments: # # # # * The "X-BeenThere: Listname@sitename.com" header # # generated by many mailing lists is wonderful to sort on. # # # # * "^Resent-From: " (note the space) is great too. # # # # * "TO" is different from "To" and you mustn't put a # # a space after "TO". It catches "To: " and "Cc: " but it # # won't catch everything, unfortunately. # # # # * Making the folder not -quite- the list name means you # # can save mail from it to a folder named for the list. Can # # be handy. # # # # * Some lists are indeed a pain to match everything on! # # # # Quick summary for adding your own or changing these: the # # general format for putting an email into a folder and not # # doing anything fancy to it first is: # # # # :0: # # * # # # # # # The ^ sign in my recipes is the sign procmail understands as # # "start of the line", so "^From" matches the word "From" when # # it's the start of a header. # # # # The "IN." at the start of folder names is not necessary: # # that's just my naming system. Stolen, like everything else, # # from a friend's example. It has the benefit that with my # # mail-reader (mutt), which sorts alphabetically, all of them # # show up first (capitals are earlier in the alphabet if # # you're a computer...) and I can save them easily: from # # IN.blah to blah. If you want to call the folders blah-spool, # # or just blah, then cool. That'll work, too. # ################################################################ ################################################################ # I hardly use TO now, but here's an example in case. # ################################################################ :0: * ^TOlynx-dev@sig.net IN.lynx-dev ########### # bugtraq # ########### :0: * ^Sender:.*Bugtraq List IN.bugtraq ######################### # gnome CVS commit list # ######################### :0: * X-BeenThere: cvs-commits-list@gnome.org IN.cvs-commits ############## # gnome-list # ############## :0: * ^X-BeenThere: gnome-list@gnome.org IN.gnome-list ############################################################### # linuxchix lists: there are several mailing lists here all # # going into the same folder. # ############################################################### :0: * ^X-BeenThere: grrltalk@linuxchix.org IN.linuxchix :0: * ^X-BeenThere: issues@linuxchix.org IN.linuxchix :0: * ^X-BeenThere: techtalk@linuxchix.org IN.linuxchix ############## # mutt-users # ############## :0: * ^TOmutt-users@mutt.org IN.mutt-users :0: * ^Sender: owner-mutt-users@mutt.org IN.mutt-users ################################################# # Procmail list # # ...be aware that everyone on this list # # seems to have monster spam filters and thus # # to be completely unconcerned at the huge # # amount of spam it gets: you will either need # # spam filters or tolerance to find the good # # stuff. (I am not subscribed now, but that was # # the case when I was.) # ################################################# :0: * ^TOprocmail@Informatik.RWTH-Aachen.DE IN.procmaillist ####################################################### # Red Hat announce -- very handy for security updates # ####################################################### :0: * ^X-BeenThere: redhat-announce-list@redhat.com IN.rh-announce :0: * ^X-BeenThere: redhat-watch-list@redhat.com IN.rh-announce ################################################################ # Splitting digests # # # # You don't need to do this, but this seems to be another very # # popular thing to do with procmail. If you're on mailing # # lists using the digest option, sometimes you may want to # # split the digests back up into the original emails. There is # # (of course) more than one way to do this: # # # # (1) don't bother: just read through all the digest in one # # big lump. Simple, easy, and great until you find someone # # sent a 500-line postscript file or a giant jpg which got # # included into the digest :( # # # # (2) use a mail-reader such as mutt, and if you suddenly want # # to split a digest up, then whilst reading the message, hit # # | formail +1 -ds # # which will put the results into your main inbox. If you want # # it in a particular folder (like the one you're reading), do # # | formail +1 -ds >> foldername # # # # (3) make procmail (or formail, actually), split it up ready # # for you to read. # # # # So if you want to have each digest automatically split up # # by procmail as it arrives, and to read each message # # individually, then here's some examples of what you can put. # # The first two lines are exactly the same. The third one has # # a pipe (vertical line) symbol at the start, and then the # # command you're piping it through. # # # # Yes, I picked a notoriously heavy-traffic one for the first # # example... And it -should- work, but it's not a list I read, # # sorry! # # # # Instead of this: # # :0: # # * ^Sender: owner-linux-kernel@vger.rutgers.edu # # IN.linux-kernel # # ...you want this: # # :0: # # * ^Sender: owner-linux-kernel@vger.rutgers.edu # # | formail +1 -ds >> IN.linux-kernel # # # # Da-dah! That's all. # # # # And for those where the list name changes and that's what # # you're matching patterns on, instead of this: # # :0: # # * ^TOlistname@somesite.org # # IN.listname # # ...you want this: # # :0: # * ^TOlistname-digest@somesite.org # # | formail +1 -ds >> IN.listname # # # # Magic :) # ################################################################ ################################################################ # That's it. Any email that doesn't match any of the recipes # # above goes into my usual place for email, which until I read # # it is /var/spool/mail/hobbit. Procmail appears to know about # # that without being told. # # # # # # It is possible that now you have everything in different # # folders, you want to read with a cool program which does # # cool things like display by thread or which understands you # # when you tell it "These are mailing lists" and does handy # # things as a result. If you do, and you discover Mutt, you # # might want to look at my muttrc which is probably next to # # this file. # # # # Have fun! # # -- Telsa # ################################################################