Derrick Green asked,
| I have some recipes that egrep bounced majordomo list message bodies for
| "From:" headers of certain senders. A problem comes up when people quote
| an entire From: header of the message to which they are responding. My
| egrep then will find the quoted "From:" header of a different person who
| is on my auto-approve list, and approve the message when it shouldn't.
| How can I set this recipe to only look at the first occurence of the From:
| header?
|
| My current recipe looks something like this:
|
| :0 B
| * ^From:.*(address1.com|address2.com|address3.com)
| | approve_message
Hmm. If you were parsing the head, I'd recommend filtering it through
formail -u From:, but we can take advantage of one thing in procmail:
the MATCH facility will do its extracting on the earliest possible place
in the search area.
# If the body has more than one occurrence of ^From:, procmail will
# extract the MATCH on the earliest one it finds.
:0B
* ^\/From:.*
FROM=$MATCH
:0
* FROM ?? (address1\.com|address2\.com|address3\.com)
| approve_message
If what you needed had been the *last* From: line in the body, it wouldn't
have been nearly so straightforward.