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