A Return-Path header shows where bounce messages and other delivery failures should be sent. By default, this address is set to the From Address, but you can customize the address to point to a custom address\domain instead. JangoMail/JangoSMTP will still handle bounces.
Return-Path header also goes by other names:
- MAIL FROM
- bounce address
- reverse path
- envelope from
To enable a custom Return-Path, you will need to provide a different envelope-sender address than the From Address. The destination MX server will always create the Return-Path header using the envelope-sender address, if it does not exist, it uses the From Address.
If you send an email from "firstname.lastname@example.org" with no envelope sender address, the Return-Path header will be "email@example.com".
If you send an email from "firstname.lastname@example.org" with an envelope sender address of "email@example.com", the Return-Path header will be "firstname.lastname@example.org".
How to Set Custom Return-Path Header via API
Set the envelope-sender address via API by using the option mailfromaddress:
We will use that value as the envelope-sender address; the destination MX server will use that to write the Return-Path header.
How to Set Custom Return-Path Header via SMTP Relay
Set the envelope-sender address via SMTP relay by passing in a custom header:
See here for more information on customizing relay messages with the use of a SMTP header.
When our relay servers see this header, they will take action on whatever options are passed in and then delete that header.
How to Set Custom Return-Path Header in the User Interface
Specify the envelope-sender address in Campaign Settings > Envelope-Sender Address:
DO NOT include Return-Path header in your SMTP message through the relays. This will end up getting overwritten by the destination MX server, or in some cases they will leave it and create a second Return-Path header.
If using a custom Return-Path header, it becomes even more important to make sure your SPF record is completely valid and authorizes your sending with JangoSMTP. We also highly recommend the use of a DMARC record.