Procmail recipe – smart recipes

Standard

Smart recipes

I use the following handy recipe to forward puzzles that any friend sends to me, while I keep a copy of it myself. That is, I have to perform two tasks at the same time. Here’s how you can go about it:

# forward puzzles to a friend
#and also keep a copy
:0
* ^Subject:.*(puzzle)
{
  :0 c
  ! myfriend@buddy.com

  :0
  puzzle
}

Here we use a nested block (enclosed in braces) instead of an action line. This block allows us to put multiple recipes within it, which are used only if the parent recipe is true.

In both the recipes in the block, we don’t have any condition statements. In the first action, the c flag is used to copy the message. Typically, a message will only run through the first recipe that is true. That is, if we don’t use the c flag, we can’t run the mail through the second recipe. The bang (!) before the email address indicates we want to forward the mail. The second recipe in the block delivers the mail to the puzzle directory.