procmail
[Top] [All Lists]

Capture match to variable?

2001-06-15 06:21:52
Hello all:

I want to insert a custom header based on what was matched in a regexp, so I can have the header include why mail was bounced or re-routed. Here is a very basic example:

:0H
 * Subject.*(MAILTEST|FUNTIME)
 {
        :0f
        | formail -I "TEST: Found test header $1"
 }      

In the regexp that I am familiar with, (MAILTEST|FUNTIME) in parens would record whatever it matched into /1 or $1. This seems to not work in this case or the state of the recording is passed when it gets to the action. Is there a work around to capture the matched text to a variable?

What I really want to do is something like this:

:0BH
 * ^Content-(Type|Disposition):.*name=.*\.(exe|com|zip|vbs|shs|hta|scr|chm)
  *! ^From(_dot_)*knowngoodaddress(_at_)mydomain(_dot_)com
 {
        :0f
          | formail -I "X-VIRUSWARNING: This file had a $2 attachment"
        :0:
        ! suspectfiles(_at_)mydomain(_dot_)com
 }

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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