These are notes to a presentation during Spring 2002.
- PowerPoint presentation
- Procmail presentation, notes, and examples
- Same as above, in tar/gz archive (from command line: tar xzvf procmail.tgz)
What is Procmail?
Procmail processes e-mail being receivedMail 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 fileRecipes 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:- Header
- Patterns (0 or more; 0 patterns matches everything)
- Action
Sequence of Delivering Mail
- The .procmailrc is sourced when mail is received
- For each recipe:
- If it matches, execute the specified action and quit
- Otherwise go to next recipe
- If there are no more recipes, put it in the Inbox
Basic Procmail Recipes
Three types: Sorting, Forwarding, ProgramSorting Recipes
Just put the folder name at the end of recipeDefault to the $HOME/mail folder
Forwarding Recipes
Put an exclamation mark (`!') before the e-mail to forward toMultiple addresses accepted
Use `:0c' to keep a copy yourself
Program Recipes
Put a pipe (`|') before the program lineUseful 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-compatibleBy 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, E | Run this recipe based on whether previous recipe ran |
| f | Change (filter) the e-mail |
| c | Continue through this recipe (don't stop if it matches) |
File Locking
Locking is required to prevent mailbox and file corruptionNot for forwarding or for programs which don't create files (or which lock files themselves)