procmail
[Top] [All Lists]

Re: Searching Header and Body

1996-07-13 23:19:10
wlotus(_at_)greatnorthern(_dot_)net asked,

| This is how I set my Procmail to get rid of a word in the header:
| 
| :0
| * foot(_at_)*
| /dev/null

If you mean to get rid of a letter that has that word in the header, you're
almost right.  That trailing asterisk basically makes the at-sign meaningless
(remember we're working with extended regular expressions, not with shell
globbing patterns, so the asterisk has a completely different meaning).

So to test for "foot@" and not just "foot", let's make it

 :0
 * foot@
 /dev/null

You might also add the `h' flag there so that procmail will write only the
head (which is usually smaller than the body) to /dev/null and just lose the
body instead of writing the entire text, and you should put a character-that-
isn't-in-a-word marker in front of it so that you don't mistakenly do it to
some innocent party whose logname is, say, bigfoot ... which in turn leads to
another complication, so just trust me on the "()" part, as it would take us
way afield for me to explain it here:

 :0h
 * ()\<foot@
 /dev/null

| Would this then remove my need for the following?:
| 
| :0:
| * ^From(_dot_)foot(_at_)*
| /dev/null

If you execute a final delivering action on every letter that has a given
string anywhere in the header, you'd also be doing it to every letter that
has that string on any particular header line, so after

 :0h
 * ()\<foot@
 /dev/null

it would be redundant to add

 :0h
 * ^From.*\<foot@
 /dev/null

Don't bother with a local lockfile on a recipe that writes to /dev/null;
you can't make lockfiles in the /dev directory and you don't need the local
lockfile anyway, since text that just vanishes won't end up mixed with other
text that vanishes.  (I believe that newer versions of procmail ignore
requests for local lockfiles on writes to /dev/null, but it's better not to
ask for one in the first place.)

| Is there any manner to scan BOTH the head and the body for a word (in this
| case an e-mail address) and send it to dev/null? This would be the most
| efficient for me.

Yes.  Use the "HB" or "BH" flags.  (Be careful: "H" is different from "h"
and "B" is different from "b".  "H" and "B" are for the condition lines but
"h" and "b" are for the action line.  "H" and "hb" are the defaults.)

 :0HBh
 * ()\<foot@
 /dev/null

<Prev in Thread] Current Thread [Next in Thread>