Using Procmail   «Prev  Next»

Lesson 5Recipe flags
ObjectiveCompare condition and action flags.

Compare condition and action flags in Procmail

A recipe's flags modify the default procmail behavior. There are numerous flags available, but all the flags can be grouped into two categories: condition and action.

Condition flags

Condition flags modify the behavior of a recipe's regular expressions. For example, procmail performs a case-insensitive search of an email's header by default. You would use condition flags to modify this behavior.
Examples of condition flags include the following:
  1. H flags: These match the email's header against the recipe's conditions. This is the default behavior.
  2. B flags: These match the email's body against the recipe's condition. Because an email can be any size, searching the body of a message can significantly impact email processing time.

Action flags

Action flags modify the behavior of the recipe's action. By default, procmail saves the email into a specific mail folder or sends the email unmodified to an external program for processing. You could, for example, use the action flag to save a copy of the flag into other mail folders. Examples of action flags include:
  1. c flags: These instruct procmail to send a copy of the email to the recipe's action, but continue processing the email within procmail.
  2. f flags: These instruct procmail to use the action as a filter. This means procmail will send the email to the action, then receive the email back from the action, possibly modified.
Check the procmailrc man page for more flags and more information on procmail recipes.
The following example recipe shows how you could check the header and body of an email for the phrase "money," and when matched, save the email into the $DEFAULT folder. Note the use of both the H and B condition flags.
:0 HB:
* money 
$DEFAULT 

Question: How would you modify the example above so that procmail continues processing the email once it is matched?
Answer: Change the first line to :0 HBc:
Explanation: Because you want procmail to continue processing after the email's action has taken place, you must specify the
c flag 
in the first of the recipe.
In the next lesson, you'll learn to identify recipe conditions.