[exim] Re: Handle sender on forwarding

Pàgina inicial
Delete this message
Reply to this message
Autor: Sebastian Nielsen
Data:  
A: 'Mailing List'
Assumpte: [exim] Re: Handle sender on forwarding
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 "somewhere@???" will become:

MAIL FROM: youruser@???
RCPT TO: forwarded_user@???

From: youruser@???
To: forwarded_user@???


Will become:

MAIL FROM: forwarded_user@???
RCPT TO: somewhere@???

From: forwarded_user@???
To: somewhere@???
Reply-To: youruser@???


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


-----Ursprungligt meddelande-----
Från: Mihamina RKTMB via Exim-users <exim-users@???> 
Skickat: den 5 november 2023 18:49
Till: exim-users@???
Ä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:rakotomandimby@???
    [...]


In other words, if I send a message to mihamina@???, it gets 
forwarded to rakotomandimby@???.
When I test, the sender is mihamina@??? and the receiver is 
mihamina@???.
The message is effectively forwarded to rakotomandimby@???, but 
the "From:" header is kept to mihamina@???.

The problem:
GMail rejects the message because my Exim server sends a message with a 
"From:" set to mihamina@??? 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):
##   exim-users-unsubscribe@???
## 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):
## exim-users-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/