45.1. Introduction to Procmail

Procmail is a powerful program for filtering and redirecting email that would normally be sent to users' mailboxes. It can be used at both the system level to filter message for all users on your system, on a per-user basis, or both. Unlike normal Sendmail aliases, Procmail can be used to deliver messages differently depending on their headers and content. This makes it an excellent tool for blocking unwanted email, such as Spam.

When installed on a system, Procmail effectively replaces the normal mail.local email delivery command that Sendmail and other MTAs run to append a message to a user's mail file. Even though it is most commonly used with Sendmail, other MTAs such as Qmail and Postfix can be configured to use Procmail for delivery as well. As far as the program is concerned, the actual mail server in use does not matter as long as email is passed to it properly.

Procmail's primary configuration file is /etc/procmailrc, which is usually managed by the system administrator. Individual users can also create their own .procmailrc files with the same format in their home directories. The system-wide file is always read and processed first, so any rules that it contains for redirecting messages based on their content cannot be overridden by individual users.

A Procmail configuration file is divided into actions, each of which has a series of conditions and a delivery mode. The conditions determine which messages the action matches, while the delivery mode controls what happens to those that match. Procmail will process actions in order until it finds one that matches, deliver the message as specified, and then stop processing.

The configuration file can also include variable assignments that may be used by later actions or even other variables. It can also contain special conditional sections, which are lists of actions to be run only if some conditions are matches. In a way, these are like if-then statements in a programming language.

Procmail behaves pretty much the same on all UNIX-like operating systems. The only difference is the default delivery location—all Linux distributions use /var/spool/mail as the user mail file directory, while other UNIX variants such as Solaris use /var/mail. This difference, however, has no effect on the program's configuration file format or the user interface of the Procmail Mail Filter module.

Procmail is most useful when configured by individual users to perform tasks such as sorting email from different people into different mailboxes, writing to two different mail files, or dropping email from specific addresses. The Procmail Webmin module and this chapter, however, only deal with system-wide configuration. If you want a tool that lets individual users configure the program though a web interface, Usermin (covered in Chapter 47) is the program to use. It has a module with an identical interface that manages .procmailrc files instead of /etc/procmailrc.

The global Procmail configuration can be used to have mail delivered to a different directory or in a different format to that normally used by your mail server. For example, instead of users' mail being appended to the files in /var/spool/mail, it could be written to the mbox file in their home directories instead. Better still, Procmail can be set up to write to a Qmail-style mail directory, usually called Maildir and located in users' home directories.

Because it deals only with email delivered locally on your system, Procmail cannot be used for mail filtering if you use a client program such as Mozilla or Evolution to download email from your ISP's or company's server. If you do not run your own mail server but still want to make use of Procmail's features, you will need to set up Fetchmail (covered in Chapter 33) to download messages and pass them to the MTA on your system.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.152.166