On Tue, Jun 22, 2010 at 5:51 AM, Dave Evans <[email protected]> wrote: > On Mon, Jun 21, 2010 at 02:38:37PM +0300, Nikita Koshikov wrote: >> Hello exim experts, >> >> I need exim to rewrite addresses like: <u...@domain*admin> to the form >> <u...@domain>. >> >> Here is the rule I made for this: >> >> \N^(.*)\*admin(.*)?$\N $1$2 S >> >> This is working on smtp-time MAIL FROM stage as I needed, but headers >> doesn't touched by it. >> Adding one more rule without S flag didn't help and body headers From, >> Sender, etc list unrewritten data. >> >> What's wrong and how can I fix this ? > > Well on my box, rewriting aside, > > # exim4 -brw '[email protected]*admin' > Syntax error in [email protected]*admin > Malformed address: *admin may not follow [email protected] > > Since [email protected]*admin isn't a valid address (on account of "*" not being > allowed in domain names), it looks to me like you're going to have a really > hard time making it work.
Dave's right, though it took me a few minutes to prove it to myself. I thought the "Malformed address" error was lingering from other checks, but it seems to be core to rewriting. The address won't even be considered if it's invalid like that. For instance, this logically behaves the way you want, rewriting both the SMTP and Message headers when tested against user*[email protected]. \N^(.*)\*admin(.*)?$\N $1$2 Sh However, when tested against [email protected]*admin, the SMTP-time rewrite works because it is defined as not caring about the syntax. However, it looks like exim's concept of what a domain is is so ingrained that it doesn't recognize [email protected]*admin as a valid email and therefore never even attempts to apply a rewrite rule to it. I did prove to myself that the one rule/two rule thing is a red herring - it doesn't work because, in header rewrites, exim doesn't see it as an email address. I don't really understand whether this is a bug or not. My initial impression is that, in address rewriting, this is the correct behavior because it's not actually an address. I wonder if any of the more generic rewriting functionality available in routers and transports might be of more use to you. FWIW, because I was initially confused by whether the -brw output was doing the right thing, I used a cut down config file and variations of the following to find the exact behavior: swaks -t [email protected]*admin --pipe 'exim -bh 127.0.0.1 -d+rewrite -C ./configure' swaks -t [email protected] --header-To '[email protected]*admin' --pipe 'exim -bh 127.0.0.1 -d+rewrite -C ./configure' swaks -t [email protected] --header-To 'user*[email protected]' --pipe 'exim -bh 127.0.0.1 -d+rewrite -C ./configure' swaks -t user*[email protected] --pipe 'exim -bh 127.0.0.1 -d+rewrite -C ./configure' --John -- ## List details at http://lists.exim.org/mailman/listinfo/exim-users ## Exim details at http://www.exim.org/ ## Please use the Wiki with this list - http://wiki.exim.org/
