gitea icon indicating copy to clipboard operation
gitea copied to clipboard

mailer: add option to override mail headers

Open 6543 opened this issue 2 years ago • 17 comments

Add option to override headers of mails, gitea send out


Sponsored by Kithara Software GmbH

6543 avatar Nov 01 '23 04:11 6543

If I understand these headers correctly:

  • Return-Path is for bounced error e-mails only, e.g. sent by smtp servers, not by users
  • Reply-To is what the clients will reply to

So maybe you are really looking for Reply-To?

silverwind avatar Nov 01 '23 11:11 silverwind

I'll test how mailclients do react ...

6543 avatar Nov 01 '23 11:11 6543

We should only set Reply-To when it's different than From because:

Some email clients issue a warning message when Reply-To: is set

I do see we already set this header on line 54, so maybe just improve it in this regard.

silverwind avatar Nov 01 '23 11:11 silverwind

This seems like it would conflict with the reply to issues via email functionality as that relies upon a specific address?

techknowlogick avatar Nov 01 '23 12:11 techknowlogick

Well yes i'll add a check so it does not conflict.

The usecase i try to solve: have a mail in from header witch is not "noreplay@..." but let mail clients still not replay to it (or show at least a warning)

6543 avatar Nov 01 '23 14:11 6543

I guess in any case, having this Return-Path option will be good to have, even thought it does likely not solve your use case.

silverwind avatar Nov 01 '23 15:11 silverwind

Happy to merge this as-is for the Return-Path option. Could add check to compare it to FROM and skip setting it if equal but it would need to perform rfc5322 format-splitting (John Doe <[email protected]>) to make them comparable.

silverwind avatar Nov 01 '23 17:11 silverwind

Is it really changeable from sender side?

https://www.rfc-editor.org/rfc/rfc5321

   When the delivery SMTP server makes the "final delivery" of a
   message, it inserts a return-path line at the beginning of the mail
   data.  This use of return-path is required; mail systems MUST support
   it.  The return-path line preserves the information in the <reverse-
   path> from the MAIL command.  Here, final delivery means the message
   has left the SMTP environment.  Normally, this would mean it had been
   delivered to the destination user or an associated mail drop, but in
   some cases it may be further processed and transmitted by another
   mail system.

https://stackoverflow.com/questions/1235534/what-is-the-behavior-difference-between-return-path-reply-to-and-from

Only the recipient's mail server is supposed to add a Return-Path header to the top of the email. 
This records the actual Return-Path sender during the SMTP session.
If a Return-Path header already exists in the message,
then that header is removed and replaced by the recipient's mail server.

wxiaoguang avatar May 27 '24 10:05 wxiaoguang

well yes ... it's just an edgecase to outlook

I'll make it more generic ...

6543 avatar May 28 '24 20:05 6543

just need testing if it works as expected :)

6543 avatar May 28 '24 21:05 6543

Before

image

Now

image image

6543 avatar May 28 '24 23:05 6543

BTW I just checked: Multiple headers values split on , and sub-values split on ; and I think this is true for both mail and http headers.

silverwind avatar May 28 '24 23:05 silverwind

BTW I just checked: Multiple headers values split on , and sub-values split on ; and I think this is true for both mail and http headers.

well we now just make a pass-through more or less ...

6543 avatar May 28 '24 23:05 6543

Interesting block syntax, where's it from? At least GFM can't seem to render it.

silverwind avatar May 28 '24 23:05 silverwind

Interesting block syntax, where's it from? At least GFM can't seem to render it.

docusaurus buildin syntax

https://docusaurus.io/docs/markdown-features/admonitions

6543 avatar May 28 '24 23:05 6543

Interesting block syntax, where's it from? At least GFM can't seem to render it.

docusaurus buildin syntax

https://docusaurus.io/docs/markdown-features/admonitions

Thanks, I see https://github.com/facebook/docusaurus/issues/7471 is related.

silverwind avatar May 28 '24 23:05 silverwind

It's better to have a test.

lunny avatar May 29 '24 01:05 lunny

It's better to have a test.

added

6543 avatar Jun 03 '24 09:06 6543