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