exim back - Set email headers so bounced emails go to a specific address
return-path smtp (5)
Here is the solution:
In the email header you can set:
From: "From Name" <[email protected]> Reply-To: [email protected] Errors-To: <[email protected]> Return-Path: <[email protected]>
From our rails app we send out some system-generated emails with the 'from' address set to [email protected] If these bounce they get sent back to this address by our mail server. However, what i'd like to do is to not have bounced emails get sent back to [email protected] but to a different address, such as [email protected]
Is there a header or something i can set in the email that will achieve this, without me having to go and investigate the vagaries of our email server? We send the mails out using exim in case that's relevant.
Errors-To is deprecated, so mail servers will typically ignore this header - most servers will bounce will to the 'envelope sender'.
This is the email address that your mail client sends as part of the connection to the SMTP server (not necessarily the From address - though it typically is the same).
I don't know Rails all that well, but I found this - although, as far as I can tell Return-Path is reset by MTAs to match the MAIL FROM information from the client, so it seems you can't actually set it.
I think the only thing you can do is set the bounce address in your server.
3 years too late, but just in case anyone else comes this way.
Return-Path is the right header but, as James Garriss pointed out above, it has to be placed there by the site performing final delivery. You can't just stick it in yourself.
If you're writing emails by connecting directly to an SMTP server then this is easy - the
MAIL FROM:<[email protected]>
to the SMTP server then bounces will be returned to
If you're not constructing SMTP, and you're running an MTA (ie. exim/etc), then you have to find a command-line switch for your MTA. For sendmail,
-f [email protected] "sets the sender's address", and this ends up as the
Return-Path in the final delivered mail, and
[email protected] will get the bounces (I do exactly this for auto-generated emails). I haven't tried this on exim, but it has exactly the same option, and it should work.
Return-Path header is written by the receiving server, not by the sending server. And as per the RFC 5321, it is the same as the address supplied in
MAIL FROM command.
Even if you set the
Return-Path header yourself, the receiving server will overwrite that.
Now, here's the thing, the address in the
MAIL FROM command and the address in the
From header can be different. The receiving user does not see the
MAIL FROM address. They only see the
From header address.
So, if you want to ignore the bounces or want them to go to a specific address, you should use that address in the
MAIL FROM command.
But in the
From header, you can just use
[email protected] - the user will see this address.
To simplify a bit more, you send the email from
[email protected] address. The receiving server will send the bounces to this address.
To show your user the
[email protected] address instead of
handle_bounce... address, set the
From header in the raw email MIME message to the
I recently got a no-reply email from Bitbucket. Here's the raw message:
Return-Path: <[email protected]r.atlassian.com> From: "Atlassian Bitbucket" <[email protected]> To: <[email protected]> Subject: Continuous delivery, without the headache. Date: Wed, 28 Feb 2018 12:40:53 -0600 MIME-Version: 1.0 Reply-To: "Atlassian Bitbucket" <[email protected]mailer.atlassian.com> ... message body ...
As you can see, the
Return-Path is an address dedicated to handle bounces. But the
From address is a
[email protected] mail. What that means is this email was actually sent by this bounce handling address, not by the noreply address.
You can also see the
Reply-To header, which is dedicated to handle replies, if a user replies to no-reply emails. Those replies are probably discarded right away.