procmail
[Top] [All Lists]

How to capture the string matched by recipe

2007-11-14 17:02:27
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
happens. 

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

  :0 
   * 
^(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}/grep.pl

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

     :0
      ForeignBunkem.in
  }

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




____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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