How to capture the string matched by recipe

reader at reader at
Thu Nov 15 00:59:12 CET 2007

I might have once had a way to do this but its lost in the deep old
creases of my brain somewhere.

I want to figure out a way to capture and write into a header the
string that my procmail recipe matches.  I want to see it in the
message under some known header.  

It seem a bit daunting to come up with the search string that will
find that info on this forum.

I know how to do the writing with formail but capturing the string or
strings is where I'm drawing a blank.

I mean, I know how to get it done by piping the message thru a small
perl script that uses the same regex as the procmail recipe.  But that
seems really awkward.

Seems like there would be some way using the MATCH operator but
procmail doesn't know what header holds the match until the match

A procmail regex aimed at foreign mail plus formail plus a homeboy
script looks like this (A bit overdone while I get right): 

   * ^(Subject|Message-ID|From|Received):.*\.[a-z0-9][a-z0-9]*\.(ar|br|cl|ch|cn|co|cz|hu|it|jp|kr|mx|pe|pl|ro|ru|th|tr|tw|ua|uk)[^a-z0-9.]
     :0 wf
      | formail -I "X-DumpMatchHere: $time"

     :0 wf
      | ${SCRIPTS}/

     :0 wf
      | formail -I "X-GotIt: Done"


Like I said, its a bit awkward... 
How can I grab the match a little more gracefully?

More information about the procmail mailing list