procmail
[Top] [All Lists]

Re: Regexp help

2002-04-26 12:26:17
What I'm trying to do is set up a domain-wide filter (called with -m as a
postfix transport).  I have postfix (as arg $2) passing a list of
recipients from the envelope.  I need to take the first recipient from
that arg and parse the domain out of the address (unfortunatly postfix
doesn't deliver that variable in any way to a piped transport).

I can see from all the FAQ's, etc. how to go about parsing from a header
and doing an extraction but I can't see how to do this from an existing
variable.  Can anyone give me a pointer?

To test against a variable (say $VAR) you use '??' on the condition
line.  For example:

    :0:
    * VAR ?? blah
    mymailbox

will deliver to 'mymailbox' if $VAR contains 'blah'.

So I think that what you're asking for is something along the lines of:

    MYARG=$2

    :0:
    * MYARG ?? \<interesting\.domain\.kom\>
    mymailbox

Is that the sort of thing you want?

As an aside, you might expect (since you have the thing in which you are
interested stored in the variable $2) to be able to do something like:

    :0:
    * 2 ?? \<interesting\.domain\.kom\>
    mymailbox

to test the variable $2 directly...but that doesn't seem to work.  At
least not in version 3.15.2

Hope that helps,
Martin
-- 
Martin McCarthy                 /</    http://procmail.non-prophet.org
    `Procmail Companion'        \>\
     Addison Wesley             /</                  PGP key available
_______________________________________________
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>