Correct email headers for delivering mailing list mail
Asked Answered
L

2

16

I'm writing an application that allows users to send email to dynamically-created mailing lists. For example, a user can send an email to [email protected] (the site is a league management site for sports leagues) and the email will be sent to everyone on that users's team. I'm trying to figure out what the email headers should be to deliver the email correctly and make all the From and To fields look right.

In Gmail, when you get an email from a mailing list (I'm looking at an email from google groups), it says that it came from the person who sent it and that it was sent to the list address, yet the email was delivered to me. My address doesn't appear in any of headers except in the Delivered-To: header. Is that some Google magic, or can I do the same thing?

Bonus question: I'm using Postfix+OpenDKIM to sign the emails. It will sign the message if the From domain matches the one I specified, but not if the Sender domain matches. How can I tell it to use the Sender domain instead.

Leucopoiesis answered 16/6, 2011 at 21:21 Comment(0)
B
29

From: and To: headers are for 'display purposes' (this is what is presented in the users email application as sender and recipient). They don't have to match to the real sender/recipient of a email message which are called "envelope sender"/"envelope recipient" and are specified in the smtp protocol ("MAIL FROM:...." "RCPT TO...").

Example:

Mail comes from [email protected], goes to [email protected] and is being delivered to [email protected]:

From Alice to The list Server:

Envelope Sender: [email protected]
Envelope Recipient: [email protected]
From Header: [email protected]
To Header: [email protected]

From the list Server to bob:

Envelope Sender: [email protected] (so error messages go to the list server, not to alice!)
Envelope Recipient: [email protected]
From Header: [email protected] (Bob sees Alice as the sender, this is not modified by the list server)
To Header: [email protected] (again, not modified by the list server)

Optional: Reply-To header: [email protected] (So, if bob presses reply, the reply goes to the list - added by the list server ) - beware: some people do not like reply-to header munging

Additional headers:

Some email clients also understand these additional headers and present special mailinglist features to the user:

  • list-Id
  • list-Post
  • list-help
  • list-unsubscribe
  • list-owner

https://www.ietf.org/rfc/rfc2919.txt https://www.ietf.org/rfc/rfc2369.txt

Also, you could add a header

Precedence: bulk

which for example tells intelligent out-of-office implementations not to send out-of-office replies to the list. But this is discouraged by RFC 2076.

Baudelaire answered 17/6, 2011 at 8:6 Comment(4)
Thanks, that's perfect. I finally understood the difference between the envelope and the message headers. FYI, Google sets their Precedence header to list, not bulk.Leucopoiesis
@lyoshenka DO NOT set reply-to. This violates RFC2822 and completely breaks mailers. It also leads to privacy issues if someone hits reply expecting it to be private. Reply-To must only be set by the message author.Gadroon
I added a warning and a link to the mailman page explaining header munging. Some lists do it, some don't.Baudelaire
You should also include the Sender header: [email protected], to be completely correct as the list is sending on behalf of Alice.Wallford
L
-1

Looks like OpenDKIM always uses the From: header so you have to resort to just signing all your emails. See this for instructions.

Leucopoiesis answered 18/6, 2011 at 0:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.