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