Procmail


In email systems, procmail, a mail delivery agent, can sort incoming mail into various directories and filter out spam messages. Procmail is stable, but no longer maintained, and a number of security vulnerabilities have been discovered since its last release. Users are advised by procmail's last maintainer, Philip Guenther, to use an alternative tool, because procmail is not suited for MIME traffic.

Replacements

Procmail was an early example of a mail filtering tool and language. Procmail is no longer maintained, and is known to have multiple security vulnerabilities. Despite this it still remains in wide use as the security issues are not widely known, migration can be difficult, especially for those who have complex filters developed over years, and some see its capabilities as better than available alternatives.
The procmail mail delivery agent is generally not started from the command line, but is usually invoked by mail delivery subsystems, such as a mail transport agent, or from a mail retrieval agent.
This makes the mail processing event-driven. The companion tool formail allows procmail to be used in batch-processing on mail that already is in a user's mailbox.

Paradigm

Procmail is a data-driven programming language, similar to earlier line-oriented languages such as sed and AWK: it specifies conditions to match and actions to take on matching, in the form of "recipes". This approach has been followed by later languages such as maildrop and sieve.

Recipes

The procmail agent uses recipes to determine where to deliver the various mail messages.

Elements of a recipe

Each recipe that procmail uses consists of:
Recipes used by procmail can be conditional or unconditional. If the conditions are left out, the recipe is unconditional.

Types of recipes

Procmail has two kinds of recipes:
Recipes are read from top to bottom. The first delivering recipe terminates the delivery process.

Conditions

Conditions are usually extended regular expressions, although there are other forms of condition also.

Basic operation

The procmail tool reads mail messages given to it from standard input. The procmail tool will process the recipes before distributing the mail messages into the appropriate mailboxes.

Pitfalls

By default, procmail will "bounce" undeliverable mail back to the sender. New users should be warned not to test new delivery recipes by running procmail on their existing mailboxes, since this could result in error messages being sent to all one's email contacts.

Other operations

Other common operations carried out with procmail include filtering and sorting of emails into different folders according to keywords in from, to, subject, text of the mail, or sending autoreplies, but more sophisticated operations
are also possible.

Spam filtering

A common practice is to let procmail call an external spam filter program, such as SpamAssassin. This method can allow for spam to be filtered or even deleted.

Managing mailing lists

The procmail developers have built a mailing list manager called SmartList on top of procmail.