19.4. Mail Delivery Agents
Red Hat Enterprise Linux includes two primary MDAs, Procmail and
This section details only Procmail. For information on the
Procmail delivers and filters email as it is placed in the mail spool file of the localhost. It is powerful, gentle on system resources, and widely used. Procmail can play a critical role in delivering email to be read by email client applications.
Procmail can be invoked in several different ways. Whenever an MTA places an email into the mail spool file, Procmail is launched. Procmail then filters and files the email for the MUA and quits. Alternatively, the MUA can be configured to execute Procmail any time a message is received so that messages are moved into their correct mailboxes. By default, the presence of
/etc/procmailrcor of a
~/.procmailrcfile (also called an rc file) in the user's home directory invokes Procmail whenever an MTA receives a new message.
By default, no system-wide
rcfiles exist in the
/etc/directory and no
.procmailrcfiles exist in any user's home directory. Therefore, to use Procmail, each user must construct a
.procmailrcfile with specific environment variables and rules.
Whether Procmail acts upon an email message depends upon whether the message matches a specified set of conditions or recipes in the
rcfile. If a message matches a recipe, then the email is placed in a specified file, is deleted, or is otherwise processed.
When Procmail starts, it reads the email message and separates the body from the header information. Next, Procmail looks for a
rcfiles in the
/etc/procmailrcsdirectory for default, system-wide, Procmail environmental variables and recipes. Procmail then searches for a
.procmailrcfile in the user's home directory. Many users also create additional
rcfiles for Procmail that are referred to within the
.procmailrcfile in their home directory.
19.4.1. Procmail Configuration
The Procmail configuration file contains important environmental variables. These variables specify things such as which messages to sort and what to do with the messages that do not match any recipes.
These environmental variables usually appear at the beginning of the
~/.procmailrcfile in the following format:
In this example,
env-variableis the name of the variable and
valuedefines the variable.
There are many environment variables not used by most Procmail users and many of the more important environment variables are already defined by a default value. Most of the time, the following variables are used:
DEFAULT— Sets the default mailbox where messages that do not match any recipes are placed.The default
DEFAULTvalue is the same as
INCLUDERC— Specifies additional
rcfiles containing more recipes for messages to be checked against. This breaks up the Procmail recipe lists into individual files that fulfill different roles, such as blocking spam and managing email lists, that can then be turned off or on by using comment characters in the user's
~/.procmailrcfile.For example, lines in a user's
~/.procmailrcfile may look like this:
MAILDIR=$HOME/Msgs INCLUDERC=$MAILDIR/lists.rc INCLUDERC=$MAILDIR/spam.rcTo turn off Procmail filtering of email lists but leaving spam control in place, comment out the first
INCLUDERCline with a hash sign (
#). Note that it uses paths relative to the current directory.
LOCKSLEEP— Sets the amount of time, in seconds, between attempts by Procmail to use a particular lockfile. The default is
LOCKTIMEOUT— Sets the amount of time, in seconds, that must pass after a lockfile was last modified before Procmail assumes that the lockfile is old and can be deleted. The default is
LOGFILE— The file to which any Procmail information or error messages are written.
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
SUSPEND— Sets the amount of time, in seconds, that Procmail pauses 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
INCLUDERCoption, 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 more information. This option is useful for debugging.
Other important environmental variables are pulled from the shell, such as
LOGNAME, the login name;
HOME, the location of the home directory; and
SHELL, the default shell.
A comprehensive explanation of all environments variables, and their default values, is available in the