Filtering Electronic Mail
Procmail is a program which understands
regular expressions and will act on your mail according to regular
expressions you specify.
The man page for
procmail is good, but here are some
quick pointers to help you get started.
Here are the steps necessary to enable
in your environment.
- Create a rules file (see below). It can be
named anything, but
procmail will look for a file
.procmailrc. If you name it something else,
you'll have to put that on the command line.
procmail in your
If you want to have mail
filtered and delivered to your mailbox, you can put
procmail and your userid into your
.forward file. The following line in your
.forward file will enable procmail:
Note that the full path to the
procmail program is
necessary. Note also that this path has to be the correct path
on the mail server, and that may or may not be the
same as the path to procmail on an interactive server. Use
If you decided to name your rules file something other than
.procmailrc, name it on the command line, like
"| /usr/cs/bin/procmail /home/mst3k/Mail/rules"
That's all that you have to do to enable
The Rules File
The Rules file is parsed by
procmail a little like a shell
script. It uses the same comments and variable assignment syntax.
Rules, however, have their own syntax. These are explained briefly
below. To get the best information on all the fine details, see the
Any variable can be created and assigned to, just like in a shell
script. Some environment variables, however, have special meaning to
procmail. Here is a list of important ones and good
default settings for them:
- Variable: DEFAULT
- Good Default: /var/spool/mail/userid
- This controls the default behavior of
when it has no rule specifying what to do.
- Variable: MAILDIR
- Good Default: $HOME/Mail
- This specifies the directory where
store files that it writes, if no absolute path is given.
- Variable: LOGFILE
- Good Default: /dev/null
- Specifies the file where
procmail logs its
activity. It's best to leave this set to
/dev/null unless you're tracking down a problem.
The log file tends to grow without bounds over time.
- Variable: UMASK
- Good Default: 077
- Sets the default permission for files created by
077 sets the files such
that only you can read or write them by default. See the man
umask(1) for more information on what
this number means.
An Example procmailrc File
procmail(1) man page for more information. Most of the basic
functionality and some advanced functionality is demostrated in