Hi,
A potential simpler way to do this. I tested this on our configuration
and it worked fine. Note that this doesn't rewrite the headers, but
rather acts like regular email forwarding.
A single router:
onbehalf-forward:
driver = redirect
domains = MYDOMAIN.COM
local_part_suffix = +onbehalf
condition = ${if match{$local_part}{\N^([^+]+)\+([^+]+)\N}}
data = ${sg{$local_part}{\\\+}{\@}},[email protected]
no_verify_sender
When using local_part_suffix, the suffix must be present before the
router is accepted, and it is stripped from $local_part before any
other checks, including the condition check. The no_verify_sender
prevents sender addresses from using this format during ACL verification.
The extra backslashes on the \\\\+ part of the ${sg} function is
required to make it be treated as a plus sign and not as a regex +.
May not be exactly what you want, but thought I'd throw it out there.
--
Dean Brooks
[email protected]
On Wed, Jul 03, 2013 at 10:08:28PM +0100, Alex Roman wrote:
> Hi,
>
> I'm hoping a kind soul can help. I did read docs and made some
> steps, but am a bit stuck and am also new to Exim.
>
> Exim is handling mail for mydomain.com. I managed to have emails
> sent to [email protected] delivered to
> [email protected] (yes I know it's prone to open relay). I'm using this
> global rewrite pattern under "begin rewrite" to do that:
>
> \N^([^+]+)\+([^+]+)\[email protected]$\N $1@$2 Ttcb
>
> Works fine, messages are indeed delivered to [email protected].
>
> But I want such emails to also be copied to [email protected],
> where "admin" is an alias for "root" in /etc/aliases. This is where
> I'm stuck.
>
> I tried with a redirect router:
>
> onbehalf:
> debug_print = "R: copy onbehalf messages"
> driver = redirect
> data = #Exim filter\n\
> if "$h_to:" contains "+onbehalf"\n\
> then deliver [email protected]\n\
> endif
> allow_filter
> #check_local_user
> user = root
> #unseen
>
> According to the debug output, the filter in this router fails
> because the address has already been rewritten before the router is
> executed. Doesn't matter if it's the first router after "begin
> routers" or last.
>
> Looking at the debug output, I see that Exim reports adding a useful
> X-rewrote-original-recipient header:
>
> >>Headers after rewriting and local additions:
> * To: [email protected]
> T To: [email protected]
> Subject: test routing
> I Message-Id: <[email protected]>
> * X-rewrote-original-recipient: [email protected]
> F From: [email protected]
> Date: Wed, 03 Jul 2013 20:33:13 +0200
>
> I tried to change the redirect filter to the following:
>
> data = #Exim filter\n\
> if "$h_X-rewrote-original-recipient:" contains "+onbehalf"\n\
> then deliver [email protected]\n\
> endif
>
> But the debug output reports that X- header to be empty "":
>
> --------> onbehalf router <--------
> local_part=SNIPPED domain=gmail.com
> R: reply to mydomain.com review invitation
> calling integru_invitereply router
> rda_interpret (string): #Exim filter\nif
> "$h_X-rewrote-original-recipient:" contains "+onbehalf"\nthen
> deliver [email protected]\nendif
> expanded: #Exim filter
> if "" contains "+onbehalf"
> then deliver [email protected]
> endif
>
> Any clues would be greatly appreciated.
>
> Alex.
>
> --
> ## 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/
>
--
## 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/