Re: [exim] Replace From with To for forwarded mails and al…

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Sebastian Nielsen
Datum:  
To: exim-users
Betreff: Re: [exim] Replace From with To for forwarded mails and also encapsulate email.
I really don't understand this hostility against modifying email.
Yes, I know that it isn't RFC compliant for an MTA to modify email. But its
surely possible, and in certain situations, good to do it.

Manage to solve most of the problems.

Settings errors_to = $local_part@INSERT_DOMAIN_HERE in the redirect router
Solved the MAIL FROM issue for me.

Now to the From: header part that caused DMARC to go nuts:

Added two small "warn" section, that adds the original From: to the
Reply-To: instead - to not sabotage the Reply button in Email clients
(unless its already set - then the sender wants the replies to go that way),
but also add a X-Forwarded-From: header, that the recipient can use to
control their inbox filters for forwarded email:

warn
    condition = ${if !def:h_reply-to:}
    add_header = Reply-To: $h_from:
  warn
    add_header = X-Forwarded-From: $h_from:


Then I added a section which simply rewrites forwarded email:

headers_rewrite = *@* "${if match
{$return_path}{INSERT_DOMAIN_HERE}{$return_path}fail}" fs

in the SMTP transport, which then replaces the From: header with the
original recipient (ergo the account with a forward configured)
(INSERT_DOMAIN_HERE prevent this from happening with domains that uses
normal mailboxes, ergo which isn't forward. Only one domain on my system
uses forwards)

Isn't a perfect situation, but totally fine for me.
And my mail gets deliivered with PASS/PASS/PASS on SPF/DKIM/DMARC even when
forwarding from accounts that have aligment set to strict.

So happy to solve the problem myself, but I think this hostility against
something that doesn't perfectly fit into the RFC needs to be toned down.

Best Regards, Sebastian Nielsen

-----Ursprungligt meddelande-----
Från: Exim-users <exim-users-bounces+sebastian=sebbe.eu@???> För John C
Klensin via Exim-users
Skickat: den 21 april 2020 02:16
Till: Shamim Shahriar <shamim.shahriar@???>
Kopia: Exim-users <exim-users@???>
Ämne: Re: [exim] Replace From with To for forwarded mails and also
encapsulate email.



--On Monday, April 20, 2020 18:10 +0100 Shamim Shahriar via
Exim-users <exim-users@???> wrote:

> On 20/04/2020 17:34, Sebastian Nielsen via Exim-users wrote:
>> Correct, thats what I want to do. But ideally I want to also
>> replace the MIME From: in the email (but also preserve the
>> original one). By encapsulate the email.
>>
>> Check this email I send here. You see that its in a attached
>> .eml file. Mailman does this, but I want to implement
>> something similiar for exim, propably by using a system
>> filter.
>>
>> So a email that arrives like this and are bound for
>> fwdaccount@??? : ***************
>> MAIL FROM: hey@???
>> RCPT TO: forwarded@???
>> DATA
>> From: hey@???
>> To: forwarded@???
>> Subject: Hi!
>> Content-Type: text/plain
>>
>> Hey there!
>> ***************
>>
>> Is forwarded like this:
>> ***************
>> MAIL FROM: forwarded@???
>> RCPT TO: fwdaccount@???
>> DATA
>> From: forwarded@???
>> To: fwdaccount@???
>> Subject: Fwd: Hi!
>> Content-Type: message/rfc822
>>
>> From: hey@???
>> To: forwarded@???
>> Subject: Hi!
>> Content-Type: text/plain
>>
>> Hey there!
>> ***************
>>
>>
>
> Hi Sebastian
>
> As Jeremy has pointed out, that is NOT the task for the MTA.
> You can use various different additional programmes to do
> this. In fact, if I am not mistaken, asking the MTA to do what
> you are asking might even violate the RFC (appreciate if
> someone could please confirm).


For whatever it is worth, confirmed. While RFC 5321 has a lot
of language in it about exceptions for exceptional
circumstances, the intent is clearly (unless the author screwed
up) that MTAs simply do not tamper with whatever comes between
DATA (or equivalent) and that CRLF.CRLF except to add trace
fields at the top.

> Also, please think of the consequence. Most MUAs rely on the
> header data to do various fun things -- i.e., organise by
> thread, apply filters, and so on. To and From are not the only
> headers -- there are more to it. If you are putting all the
> former headers into the body -- what do you think is likely to
> happen? I can assure you that I, as a recipient, will be
> seriously unhappy and confused by that!
>...


Yep. There are cases in which one would want to completely
encapsulate a messages while/when forwarding it -- that is what
MIME's message/rfc822 and message/global are about -- but those
actions occur at MUA level, not the MTA one.

>...


-- your friendly RFC 5321 author and exim user.



--
## 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/