Product SiteDocumentation Site

13.4. メール配送エージェント

Fedora includes two primary MDAs, Procmail and mail. Both of the applications are considered LDAs and both move email from the MTA's spool file into the user's mailbox. However, Procmail provides a robust filtering system.
This section details only Procmail. For information on the mail command, consult its man page (man mail).
Procmail を使用すると、ローカルホストのメールスプールファイルにある電子メールのフィルターと配送をします。 Procmail は強力で、システムリソースにやさしく、広範囲で使用されています。これは、電子メールクライアントアプリケーションで読み込まれる予定の電子メールを配送する時点で重要な役割りを果たします。
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/procmailrc or of a ~/.procmailrc file (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 rc files exist in the /etc/ directory and no .procmailrc files exist in any user's home directory. Therefore, to use Procmail, each user must construct a .procmailrc file 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 rc file. 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 /etc/procmailrc file and rc files in the /etc/procmailrcs directory for default, system-wide, Procmail environmental variables and recipes. Procmail then searches for a .procmailrc file in the user's home directory. Many users also create additional rc files for Procmail that are referred to within the .procmailrc file in their home directory.

13.4.1. Procmail の設定

Procmail 設定ファイルには、重要な環境変数が含まれています。これらの変数は、どのメッセージをソートするか、レシピに一致しないメッセージをどう処理するかなどを指定します。
These environmental variables usually appear at the beginning of the ~/.procmailrc file in the following format:
In this example, env-variable is the name of the variable and value defines the variable.
環境変数の多くはほとんどの Procmail ユーザーに使用されず、それより重要な環境変数の多くはすでにデフォルト値が定義されています。ほとんどの場合、次のような変数が使用されます:
  • DEFAULT — Sets the default mailbox where messages that do not match any recipes are placed.
    The default DEFAULT value is the same as $ORGMAIL.
  • INCLUDERC — Specifies additional rc files 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 ~/.procmailrc file.
    For example, lines in a user's .procmailrc file may look like this:
    To turn off Procmail filtering of email lists but leaving spam control in place, comment out the first INCLUDERC line with a hash sign (#).
  • LOCKSLEEP — Sets the amount of time, in seconds, between attempts by Procmail to use a particular lockfile. The default is 8 seconds.
  • 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 1024 seconds.
  • 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.
    デフォルトでは、/var/spool/mail/$LOGNAME の値が使用されます。
  • 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 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 more information. This option is useful for debugging.
Other important environmental variables are pulled from the shell, such as LOGNAME, which is the login name; HOME, which is the location of the home directory; and SHELL, which is the default shell.
A comprehensive explanation of all environments variables, as well as their default values, is available in the procmailrc man page.