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