Score:0

What exactly is Return-Path and who sets it?

us flag

This article (https://www.sparkpost.com/resources/email-explained/return-path-explained/) explains "Return-Path" as follows:

When an email doesn’t make it to its intended destination, the return path indicates where non-delivery receipts—or bounce messages—are to be sent.

and

Many senders will incorporate identifiers into the return path address to ease handling of reply and bounce traffic, referred to as Variable Envelope Return Path (VERP).

I understand this as: "As the email sender, you specify the Return-Path header".

However, given the following answer (https://stackoverflow.com/a/28494070/9878135), it seems as if the receiving server always overwrites Return-Path:

Setting the Return-Path: header on outbound email is pointless because it will be replaced by the recipient's MTA. If you want to control what gets written there, set the envelope sender (traditionally, sendmail -f [email protected])

I'm currently trying to build an email server that uses VERP for emails. Let's say "[email protected]" wants to send an email to the outside. "From" should be "[email protected]" while "Return-Path" should be something completely different (like "[email protected]"). When the outside email service can't deliver the email, it should send an email back to "[email protected]". My server can now lookup this bounce email in the database and inform [email protected] about the delivery failure.

I'm using Postfix to send and receive mails (and Python to construct them). However, it seems as if Return-Path is never received by other email services (such as Google Mail or ProtonMail). Google Mail doesn't show the header at all while ProtonMail overwrites it with the "From" address.

So who does set the Return-Path header and why can't other email services receive mine?

anx avatar
fr flag
anx
The confusion goes away as soon as you cleanly distinguish a) the "return path" the place where returns should go (these days a singular destination, the "envelope sender") and b) "Return-Path:" the header; a place to make this information available within the message (even for contexts where other envelope information is not). One a necessity of the transport, the other a useful convention at the final recipients discretion.
Myzel394 avatar
us flag
I mean the `Return-Path` header, so the address where the receiving server should send the delivery report in case of a bounce
Score:1
fi flag

Return-Path: header contains a copy of "envelope sender" address. Return-Path: header is usually (re)generated by the SMTP/MTA making delivery directly to the recipient's mailbox (after the final SMTP hop).

"Envelope sender" is an address used in MAIL FROM: command in SMTP session.

So your sending client software should set "envelope sender" => It will be (usually) copied into Return-Path:.

SMTP.sendmail(from_addr, …)

Myzel394 avatar
us flag
Why does the receiving server copy it? Isn't the point of `Return-Path` to define a **different** email address that can be used for bouncing by the server who sent the mail?
AnFi avatar
fi flag
`Return-Path:` informs the recipients about envelope sender address used in SMTP session because it is quite frequently different than `From:`. To make the information reliable the final hop SMTP/MTA server **usually** (re)creates it. Anyway: Now it is "a sacred tradition".
Myzel394 avatar
us flag
Can I avoid the last MTA from recreating it? How do newsletters use VERP nowadays when it's a "sacred tradition"? Afaik DuckDuckGo's Email Tracking Protection also still uses it nowadays to detect when a forwarded email alias could not be delivered
AnFi avatar
fi flag
Use `from_address` when calling sendmail function. Provide address copied into `Return-Path:` header. Check it yourself to be 200% sure. VERP is based on "envelope sender" address. SMTP/MTA servers use "envelope sender" and ignore `Return-Path:` header when sending bounces. `Return-Path:` merely informs the final recipient about "envelope sender".
Myzel394 avatar
us flag
Then what is `Return-Path` even used for when it gets overwritten anyway? The given article states that "When an email doesn’t make it to its intended destination, the return path indicates where non-delivery receipts—or bounce messages—are to be sent."
AnFi avatar
fi flag
`Return-Path:` makes envelope sender visible to the final recipient. "Envelope sender" defines destination for bounce emails. It creates confusion because `Return-Path:` is what the recipient sees/inspects.
Myzel394 avatar
us flag
I think you misunderstood my question. I want the server to send to `Return-Path` for bounce mails. The other user should still see `From`. `Return-Path` should only be visible to the server, so normal users should normally never see it. Just like the article says: "Many senders will incorporate identifiers into the return path address to ease handling of reply and bounce traffic, referred to as Variable Envelope Return Path (VERP)."
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.