
214 Chapter 16. Email
• MAILDIR — Sets the current working directory for Procmail. If set, all other Procmail paths are
relative to this directory.
• ORGMAIL — Specifies the original mailbox, or another place to put the messages if they cannot be
placed in the default or recipe-required location.
By default, a value of /var/spool/mail/$LOGNAME is used.
• SUSPEND — Sets the amount of time, in seconds, that Procmail will pause if a necessary resource,
such as swap space, is not available.
• SWITCHRC — Allows a user to specify an external file containing additional Procmail recipes,
much like the INCLUDERC option, except that recipe checking is actually stopped on the referring
configuration file and only the recipes on the SWITCHRC-specified file are used.
• VERBOSE — Causes Procmail to log much more information. This option is useful for debugging.
Other important environmental variables are pulled from your shell, such as LOGNAME, which is your
login name, HOME, which is the location of your home directory, and SHELL, which is your default
shell.
A comprehensive explanation of all environments variables, as well as their default values, is available
on the procmailrc man page.
16.5.2. Procmail Recipes
New users often find the construction of recipes the most difficult part of learning to use Procmail. To
some extent, this is understandable, as recipes do their message matching using regular expressions,
which is a particular format used to specify qualifications for a matching string. However, regular
expressions are not very difficult to construct and even less difficult to understand when read. Addi-
tionally, the consistency of the way Procmail recipes are written, regardless of regular expressions,
makes it easy to figure out what is going on.
A thorough explanation of regular expressions is beyond the scope of this chapter. The structure of
Procmail recipes is more important, and useful sample Procmail recipes can be found at various places
on the Internet, including http://www.iki.fi/era/procmail/links.html. The proper use and adaptation of
the regular expressions found in these recipe examples depends upon an understanding of Procmail
recipe structure. Introductory information specific to basic regular expression rules can be found on
the grep man page.
A Procmail recipe takes the following form:
:0
flags : lockfile-name
* special-condition-character condition-1
* special-condition-character condition-2
* special-condition-character condition-N
special-action-character action-to-perform
Figure 16-9. Structure of a Procmail recipe
The first two characters in a Procmail recipe are a colon and a zero. Various flags can optionally
be placed after the zero to control what Procmail does when processing this recipe. A colon after
the flags section specifies that a lockfile will be created for this message. If a lockfile is to be
created, you specify its name in the
lockfile-name space.
A recipe can contain several conditions to match against the message. If it has no conditions, every
message will match the recipe. Regular expressions are placed in some conditions in order to facilitate
a match with a message. If multiple conditions are used, they must all match in order for an action to
Commenti su questo manuale