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