Yes you can do this:

In acl_rcpt:

  warn
    domains = <YOURDOMAIN>
    remove_header = dkim-signature
    remove_header = arc-seal
    remove_header = arc-authentication-results
    remove_header = arc-message-signature


In acl_data:

  warn
    condition = ${if match {$recipients}{<YOURDOMAIN\\.YOURTLD>\$}{yes}{no}}
    condition = ${if !def:h_reply-to:}
    add_header = Reply-To: $h_from:

In your redirect router:

sender_redirect:
    driver = redirect
    domains = <YOURDOMAIN>
    data = ${lookup{$local_part}lsearch{/etc/forwards}}
    errors_to = $local_part@<YOURDOMAIN>
    set = r_orep=${lookup{$local_part}lsearch{/etc/forwards}}
    set = r_isfwd=true


In your Remote_SMTP transport:

remote_smtp:
  debug_print = "T: remote_smtp for $local_part@$domain"
  driver = smtp
  dkim_sign_headers = from:date:to:cc
  dkim_domain = <YOURDOMAIN>
  dkim_selector = <YOURSELECTOR>
  dkim_private_key = /etc/exim4/dkim.key
  dkim_canon = relaxed
  headers_rewrite = *@* "${if eq {$r_isfwd}{true}{$return_path}fail}" fs : *@* 
"${if eq {$r_isfwd}{true}{\"Forwarded Email\" <$r_orep>}fail}" tw


This will rewrite envelope sender to the $local_part@<YOURDOMAIN> (by setting 
errors_to), then It will rewrite MIME From to $local_part@<YOURDOMAIN>, then it 
will rewrite To: to become "Forwarded Email" <[TARGET_ADRESS]>.
It will also dump any DKIM or ARC signatures from original sender, instead you 
sign mail yourself.


>>> This will pass servers/senders even with strict alignment. <<<


A forwarded email as this, with forwarded_user having a forward to 
"[email protected]" will become:

MAIL FROM: [email protected]
RCPT TO: [email protected]

From: [email protected]
To: [email protected]


Will become:

MAIL FROM: [email protected]
RCPT TO: [email protected]

From: [email protected]
To: [email protected]
Reply-To: [email protected]


(If Reply-To on sending mail is already set, it will not be replaced).


-----Ursprungligt meddelande-----
Från: Mihamina RKTMB via Exim-users <[email protected]> 
Skickat: den 5 november 2023 18:49
Till: [email protected]
Ämne: [exim] Handle sender on forwarding

Hi all,

I have an Exim installation where I just setup aliases.

exim.conf:

     [...]
     local_domains= @:myfoobar.com
     [...]


aliases:

    [...]
    mihamina:[email protected]
    [...]


In other words, if I send a message to [email protected], it gets 
forwarded to [email protected].
When I test, the sender is [email protected] and the receiver is 
[email protected].
The message is effectively forwarded to [email protected], but 
the "From:" header is kept to [email protected].

The problem:
GMail rejects the message because my Exim server sends a message with a 
"From:" set to [email protected] but atscom.io's SPF does not allow 
this server to send such messages.
I have no authority on senders domains SPF (that's fair).

I guess there is a setting I have to set on Exim in order to fix this?

Regards



-- 
## subscription configuration (requires account):
##   https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
##   [email protected]
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


-- 
## subscription configuration (requires account):
##   https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
##   [email protected]
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Reply via email to