404 Not Found


nginx/1.18.0 (Ubuntu)

Using Procmail

Charles Duan
FAS Computer Services
404 Not Found

404 Not Found


nginx/1.18.0 (Ubuntu)

These are notes to a presentation during Spring 2002.

What is Procmail?

Procmail processes e-mail being received

Mail is filtered based primarily based on headers (but it's your choice)

Mail can be filtered to three places: folders (mailboxes), other addresses, or programs (which might pipe to folders or other addresses...)

Procmail Recipes

Contained in the $HOME/.procmailrc file

Recipes specify what e-mail the recipe will deal with (e.g. mail from a club, from some user, sent at some time/date, etc.) and what to do with the e-mail

Generally, at most one recipe will execute, but this can be overridden

Procmailrc Syntax

Composed of three parts:
  1. Header
  2. Patterns (0 or more; 0 patterns matches everything)
  3. Action

Sequence of Delivering Mail

  1. The .procmailrc is sourced when mail is received
  2. For each recipe:
    • If it matches, execute the specified action and quit
    • Otherwise go to next recipe
  3. If there are no more recipes, put it in the Inbox

Basic Procmail Recipes

Three types: Sorting, Forwarding, Program

Sorting Recipes

Just put the folder name at the end of recipe

Default to the $HOME/mail folder

Forwarding Recipes

Put an exclamation mark (`!') before the e-mail to forward to

Multiple addresses accepted

Use `:0c' to keep a copy yourself

Program Recipes

Put a pipe (`|') before the program line

Useful for processing online forms

Patterns

The Berkeley mbox Format

Each email starts with a `From: [email] [date-sent]'

Headers are of format `[Type]: [Value]'

Regular Expressions

Egrep-compatible

By default, only matches against header

Problems with spaces: the number of spaces in a header is undefined and could include tabs

Other Patterns

!invert pattern
?Run a program; use exit code
> and <Based on size of the e-mail
$Evaluate variables, quotes, like sh

Recipe Options

A, a, E, ERun this recipe based on whether previous recipe ran
fChange (filter) the e-mail
cContinue through this recipe (don't stop if it matches)
man procmailrc contains more examples

File Locking

Locking is required to prevent mailbox and file corruption

Not for forwarding or for programs which don't create files (or which lock files themselves)

404 Not Found

404 Not Found


nginx/1.18.0 (Ubuntu)