Re: [Exim] Problem rewriting SMTP address

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Philip Hazel
Dátum:  
Címzett: John Horne
CC: Exim Users List
Tárgy: Re: [Exim] Problem rewriting SMTP address
On Fri, 10 May 2002, John Horne wrote:

> In my Exim 3.36 configure file I have the following rewriting rule:
>
> ^<?([^@]+)>?$   "${if match {$sender_host_name} \
>                             {(?i).net.plymouth.ac.uk\\$} \
>                 {$sender_address@$sender_host_name} fail}"     S


> The problem is that the above rule is almost working, but I just cannot get
> the '$sender_address' bit to work - it seems that at SMTP time, this
> variable is not set, since I get the error message (when using 'exim -bh'):
>
>   220 mary.csd.plymouth.ac.uk ESMTP Exim 3.36 #1 Fri, 10 May 2002 16:31:32
>          +0100
>   mail from: john
>   LOG: Rewrite of john yielded unparseable address: no local part in address
>   @plynms02.net.plymouth.ac.uk


Unfortunately, $sender_address is not set until after the "S" rewriting,
which happens as part of the address extraction from the command (as
does qualification).

> As it shows there is no local part in the rewritten address. If I try using
> '$1' I get the same thing.


Now that *is* weird, since it has matched the regular expression... No,
as you were. You've matched *another* regular expression as part of the
"if", which has destroyed the setting of $1 that you extracted from the
original.

I think you'll have to do this with two rewriting rules.

Rule 1: Use a regex to recognize unqualified addresses; rewrite to
"localpart@???".

Rule 2: Match on *@no.domain.supplied and use the regex you already
have, making use of $local_part. If your regex fails, rewrite back to
the unqualified address so that Exim will fail it.


--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.