On Wed, 10 Aug 2022, Olaf Hopp (SCC) via Exim-users wrote:

On 8/9/22 17:54, Andrew C Aitchison wrote:
On Tue, 9 Aug 2022, Olaf Hopp (SCC) via Exim-users wrote:

[...]

You have:
    ^(.*)@(.*)\.olddomain\.org $1@$2.newdomain.org TS

The examples suggest that:

    *@*olddomain.org $1@$2.newdomain.org TS

would be sufficient.

When using 'S' as rewriting flag you must use regular expressions.
Otherwise exim won't start:
        rewrite rule has the S flag but is not a regular expression
And I think I need the 'S' flag here, otherwise my routing fails.

Ah. I didn't know about the S flag.

In particular I doubt that you need the anchoring "^".

And also the leading '^' is necessary when using 'S'
otherwise exim also fails to start for the same reason

Odd.

Perhaps the extending patterns are forcing $1 to include
the opening "<", so that the matching ">" is never removed ?

31.9 The SMTP-time rewriting flag
---------------------------------

The rewrite flag "S" specifies a rewrite of incoming envelope addresses at SMTP
time, as soon as an address is received in a MAIL or RCPT command, and before
any other processing; even before syntax checking. The pattern is required to
be a regular expression, and it is matched against the whole of the data for
the command, including any surrounding angle brackets.

So $1 *does* include the opening "<" which is why you had to add the ">"

The rule
        ^([^<]*)@(.*)\\.olddomain\\.org $1@$2.newdomain.org TS
seems to work for me.

Without the doubled slash:
        ^([^<]*)@(.*)\.olddomain\.org $1@$2.newdomain.org TS
we would also rewrite [email protected] as [email protected]

#exim4 -C /tmp/werdna/exim.rewrite.test2 -d+all -brw "Fred Flintstone 
<[email protected]>"
                ...             ...             ...
08:46:22 240891  ╭considering: ^([^<]*)@(.*)\.olddomain\.org
08:46:22 240891  ├──expanding: ^([^<]*)@(.*)\.olddomain\.org
08:46:22 240891  ╰─────result: ^([^<]*)@(.*).olddomain.org
  sender: Fred Flintstone <[email protected]>
    from: Fred Flintstone <[email protected]>
      to: Fred Flintstone <[email protected]>
      cc: Fred Flintstone <[email protected]>
     bcc: Fred Flintstone <[email protected]>
reply-to: Fred Flintstone <[email protected]>
env-from: [email protected]
08:46:22 240891  ╭considering: ^([^<]*)@(.*)\.olddomain\.org
08:46:22 240891  ├──expanding: ^([^<]*)@(.*)\.olddomain\.org
08:46:22 240891  ╰─────result: ^([^<]*)@(.*).olddomain.org
08:46:22 240891 address match test: [email protected] 
pattern=^([^<]*)@(.*).olddomain.org
08:46:22 240891 [email protected] in "^([^<]*)@(.*).olddomain.org"? yes (matched 
"^([^<]*)@(.*).olddomain.org")
08:46:22 240891  ╭considering: $1@$2.newdomain.org
08:46:22 240891  ├──expanding: $1@$2.newdomain.org
08:46:22 240891  ╰─────result: [email protected]
08:46:22 240891 LOG: address_rewrite MAIN
08:46:22 240891   "[email protected]" from env-to rewritten as 
"[email protected]" by rule 1
  env-to: [email protected]
08:46:22 240891 search_tidyup called
08:46:22 240891 >>>>>>>>>>>>>>>> Exim pid=240891 (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>>

--
Andrew C. Aitchison                      Kendal, UK
                   [email protected]
--
## List details at https://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/

Reply via email to