Simple filtering

Recipes
Procmail reads your procmailrc from the top down and will continue until it matches a recipe. From the man page (simplified)
          A line starting with ':' marks the beginning  of  a  recipe.
          It has the following format:

               :0 [flags]
               <zero or more conditions (one per line)>
               <exactly one action line>
Each condition starts with a "*"

"^TO" is acutally shorthand for "To: or Cc: or Bcc:" and several others. If it's going to a particular destination, TO will probabaly match it. See the procmailrc man page for complete details.

The trick to filtering mailing list mail is to find some unique header that only applies to that mailing lists, usually you'll find a Sender: or X-Loop: header somewhere that is produced by the mailing list manager. This is usually different depending on the list manager.

We illustrate with an example.

NOTE: For all future examples we will omit the variable section.

LOGFILE=$HOME/.maillog               # this is very important
VERBOSE=no                           # don't tell me everything
PATH=$HOME/bin:/usr/local/bin:/usr/bin
MAILDIR=$HOME/Mail	             # where my mail directory is located

# I'm on the fvwm mailing list and all mail from this list has a
# "To: fvwm@hpc.uh.edu" or "Cc: fvwm@hpc.uh.edu" header
# This one takes the mail and puts it into my "fvwm" folder
# in my $HOME/Mail/fvwm folder
# It then exits (ie: doesn't do any further processing)

:0
* ^TOfvwm
fvwm

# all the mail from the membership@acm.uiuc.edu list gets put into my acm folder

:0
* ^X-Loop: membership@acm.uiuc.edu
acm

# any mail that doesn't match any recipies will automatically get put into $DEFAULT

Processing
By default procmail will continue to process mail until it matches a recipe and then it will quit. For example, I will never get any of the fvwm mail in my inbox because procmail stopped processing at that point. This is the easiest way to deal with multiple mailing lists.

Back: mailstat Top Next: Recipe Flags

j g r o s s @ s t i m p y . n e t