What's the difference between Sender, From and Return-Path?

EmailSmtp

Email Problem Overview


What's the difference between an email Sender, From and Return-Path value?

Example: I have a contact form where the user can input their email, would this be assigned to sender, from or return-path?

I had a quick search on the StackOverflow and couldn't find anything useful.

Email Solutions


Solution 1 - Email

So, over SMTP when a message is submitted, the SMTP envelope (sender, recipients, etc.) is different from the actual data of the message.

The Sender header is used to identify in the message who submitted it. This is usually the same as the From header, which is who the message is from. However, it can differ in some cases where a mail agent is sending messages on behalf of someone else.

The Return-Path header is used to indicate to the recipient (or receiving MTA) where non-delivery receipts are to be sent.

For example, take a server that allows users to send mail from a web page. So, [email protected] types in a message and submits it. The server then sends the message to its recipient with From set to [email protected]. The actual SMTP submission uses different credentials, something like [email protected]. So, the sender header is set to [email protected], to indicate the From header doesn't indicate who actually submitted the message.

In this case, if the message cannot be sent, it's probably better for the agent to receive the non-delivery report, and so Return-Path would also be set to [email protected] so that any delivery reports go to it instead of the sender.

If you are doing just that, a form submission to send e-mail, then this is probably a direct parallel with how you'd set the headers.

Solution 2 - Email

The official RFC which defines this specification could be found here:

https://www.rfc-editor.org/rfc/rfc4021#section-2.1.2 (look at paragraph 2.1.2. and the following)

> 2.1.2. Header Field: From
> > Description:
> Mailbox of message author
> [...]
> Related information: > Specifies the author(s) of the message; that is, the mailbox(es) > of the person(s) or system(s) responsible for the writing of the > message. Defined as standard by RFC 822. > > 2.1.3. Header Field: Sender
> > Description:
> Mailbox of message sender
> [...]
> Related information: > Specifies the mailbox of the agent responsible for the actual > transmission of the message. Defined as standard by RFC 822. > > 2.1.22. Header Field: Return-Path
> > Description: > Message return path > [...]
> Related information: > Return path for message response diagnostics. See also RFC 2821 > [17]. Defined as standard by RFC 822.

Solution 3 - Email

A minor update to this: a sender should never set the Return-Path: header. There's no such thing as a Return-Path: header for a message in transit. That header is set by the MTA that makes final delivery, and is generally set to the value of the 5321.From unless the local system needs some kind of quirky routing.

It's a common misunderstanding because users rarely see an email without a Return-Path: header in their mailboxes. This is because they always see delivered messages, but an MTA should never see a Return-Path: header on a message in transit. See https://www.rfc-editor.org/rfc/rfc5321#section-4.4

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionThe Pixel DeveloperView Question on Stackoverflow
Solution 1 - EmailShawn D.View Answer on Stackoverflow
Solution 2 - EmailnaitsirchView Answer on Stackoverflow
Solution 3 - EmailcmeidView Answer on Stackoverflow