Procmail talk

Andrew C. Bulhak <>

What is Procmail?

Procmail is a tool which runs under UNIX for automatically processing mail by matching against headers and body text with regular expressions.

What can Procmail do?

Procmail can be used for a number of tasks, which include:

From where can Procmail be obtained?

The procmail source resides at Many Linux distributions provide a precompiled procmail package.

How can Procmail be used?

From the user's .forward file

Most mail delivery agents, such as sendmail, can allow users to specify programs to pipe incoming mail through. This can be used to invoke procmail. To do this, the user's .forward file should read something such as:
"|IFS=' '&&exec /usr/local/bin/procmail -f-||exit 75 #YOURUSERNAME"

From a sendmail alias.

Mail aliases (kept in /etc/aliases) behave much like .forward files. It is thus possible to create a mail alias which will pipe incoming mail to procmail, like so:
information: |/usr/local/bin/procmail -m /etc/procmailrcs/info
This can be useful for writing "infobots" and the like.

As the site's local mail delivery agent.

procmail can be configured to take the place of a site's local mail delivery agent. This can be done with sendmail 8.8 (I think) by specifying the local_procmail feature in the file.

This has the further advantage of allowing anything after a '+' in the local part of the email address to be passed as an argument to procmail.

Procmail recipes

Procmail recipes


Mail logging and mailstat

Procmail can be configured to log all mail processed to a file whose path is set in the LOGFILE variable.

There is a utility program named mailstat which, when called with the name of this file, reads it, prints a table of statistics and deletes it. This is good for informing the user about where mail has been delivered.

My .procmailrc


* ^Sender: owner-flat-earth

* ^To:.*

* ^To:.*

* ^To:.*

* ^Sender:


# * ^To:.*@(aol\.com|juno\.com|interramp\.com|cyberpromo\.com|Recipient\ list\ suppressed)$

# :0:
# * ^From:.*
# /dev/null