[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vps-mail] proctip 0
- Subject: [vps-mail] proctip 0
- From: Scott Wiersdorf <scott@xxxxxxxxxxxx>
- Date: Thu, 25 Sep 2003 00:19:06 -0600
Because I haven't had time to finish proctut5 this week, I'm sending a
brief procmail tip ("proctip") instead. Please accept my apologies for
the missing proctut.
Today's tip:
Use the 'H' and 'B' built-in procmail variables instead of the 'H' and
'B' flags when you need to scan both headers and body in the same
recipe.
Example:
## this recipe uses 'H' and 'B' variables
:0:
* H ?? ^Subject:.*money
* B ?? call toll free
/var/log/advertising
which is the same as:
## this recipe uses 'H' and 'B' flags instead
:0 H
* ^Subject:.*money
{
:0 B:
* call toll free
/var/log/advertising
}
You can see how much more succinct and easy to read the variable
recipe is.
Discussion:
The 'H' and 'B' variables contain the message headers and body
respectively. The 'H' variable is the same as using the 'H' flag:
:0 H:
* ^Subject:.*money
And the 'B' variable is the same as using the 'B' flag:
:0 B:
* call toll free
But using them in the same recipe should be done with variables, not
flags.
There are three reasons for using variables instead of flags. The
first reason is that there is a long-standing bug in procmail that
occurs when you use the 'H' flag; the bug is that the 'H' flag will
be passed on to subsequent recipes, even if you only want to scan the
body of the message.
The second reason is that you can't distinguish between which
conditions apply to the header and which conditions apply to the
body. For example, this:
:0 HB:
* ^Subject:.*money
* call toll free
/var/log/advertising
could mean that "call toll free" could also appear anywhere in the
headers. Likewise, the subject line (though unlikely in our example)
could also appear in the body of the message. Using the variables, you
can make that distinction (even if our example is a little contrived,
there are legitimate cases where you must make the distinction).
The third reason to use the 'H' and 'B' variables instead of 'H' and
'B' flags is that it is easier to read and understand what is going on
in the recipe.
Summary:
The 'H' and 'B' built-in procmail variables contain the headers and
body of the message respectively. Using these variables instead of the
'H' and 'B' flags results in more succinct and easier to read recipes.
Scott
--
Scott Wiersdorf
scott@xxxxxxxxxxxx
======================================================================
Technical questions regarding this list may be sent to
<vps-mail-owner@xxxxxxxxxxxx>. You may request an automated help
response by sending an email with the word 'help' (w/o quotes) in the
BODY of the message (subject is ignored) to <vps-mail-request@xxxxxxxxxxxx>.
======================================================================
Main Index |
Thread Index