Re: [Exim] SMTP rewriting (again)

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Philip Hazel
Date:  
À: John Horne
CC: exim-users
Sujet: Re: [Exim] SMTP rewriting (again)
On Tue, 2 Mar 2004, John Horne wrote:

> But that is (almost) what I had and it didn't work - I used:
>
>    \N^<?([^@<>]+)>?$\N

>
> Okay so the <> are left out. But even if I include them I get an error
> (using a local part of 'fred'):
>
> LOG: Rewrite of fred yielded unparseable address: no local part in
> address @plynms01.net.plymouth.ac.uk
>
> As far as I can tell the 'match' condition is probably resetting $1 so I
> lose the original address. If I change the rewrite rule to use $0
> instead of $1 then I get the matched string '.net.plymouth.ac.uk' stuck
> in as a local part. That makes sense if 'match' is setting/resetting the
> $0, $1 etc.


Sorry, I seem to have lost your original (excessive trimming of
responses, probably) so I can't check this, but if you had a "match"
condition in the replacement then, yes, $1 is going to get reset. The
manual says this:

The condition is true if the regular expression match succeeds. At the
start of an "if" expansion the values of the numeric variable substitutions
$1 etc. are remembered. Obeying a "match" condition that succeeds causes
them to be reset to the substrings of that condition and they will have
these values during the expansion of the success string. At the end of the
"if" expansion, the previous values are restored. After testing a combi-
nation of conditions using "or", the subsequent values of the numeric
variables are those of the condition that succeeded.

If you want to use the "outside" $1 in the replacement of the match,
you'll have to use trickery, such as adding "+$1" to the subject text to be
matched and an appropriate bit of regex to pick it off for use in the
"sucess" string.



--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book