Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go

Procmail: Filter and Split Incoming Email

REVIEW The procmail package provides a powerful mechanism for filtering incoming email, to split email that meet certain criteria into separate folders, to forward different emails on to other users, and to add extra headers to your email (e.g., X-Label headers to classify your email into categories you might define).

The procmail application will be invoked on any email that arrives for you by adding the following to your .forward file:

|/usr/bin/procmail

At the heart of procmail is the .procmailrc file. This contains all the rules that are applied to an email to determine what should happen to that email.

There is potential for procmail to be invoked in rapid succession, and thus if two procmails try to write to the one file there could be a problem. Thus procmail uses lock files to ensure this does not happen. A lock file will slow procmail down ever so slightly, so it is kept as an option specified in the configuration file (.procmailrc) rather than a default.

We can use formail to process an mbox format mail file (containing a collection of email messages) to pipe each message through our procmail processing:

$ formail -s procmail < /var/mail/kayon
This is only needed if you already have quite a few emails in there, and want to put them through the filter processing.


Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.