title: How can the Return-Path header be different than the actual email bounce recipient?
body: <p>I recently moved my transactional email sending to <a href="https://mailgun.com/" rel="nofollow noreferrer">Mailgun</a></p>
  <p>It works good so far however I am wondering about the return-path header.</p>
  <p>Consider this email (I removed irrelevant header and replaced email/domain for privacy purposes)</p>
  <pre><code>Delivered-To: RECIEVER@gmail.com
  Received: by 10.76.154.104 with SMTP id vn8csp478308oab;
          Wed, 4 Sep 2013 05:04:44 -0700 (PDT)
  X-Received: by 10.50.22.105 with SMTP id c9mr1537992igf.36.1378296283817;
          Wed, 04 Sep 2013 05:04:43 -0700 (PDT)
  Return-Path: &lt;bounce+a801a1.c2b37-RECIEVER=gmail.com@my-website.com&gt;
  Received: from so254-63.mailgun.net (so254-63.mailgun.net. [198.61.254.63])
          by mx.google.com with ESMTP id k5si1620852igx.55.1969.12.31.16.00.00;
          Wed, 04 Sep 2013 05:04:43 -0700 (PDT)
  Received-SPF: ...stripped...
  Authentication-Results: ...stripped...
  DKIM-Signature: ...stripped...
  DomainKey-Signature: ...stripped...
  Received: by luna.mailgun.net with HTTP; Wed, 04 Sep 2013 12:04:42 +0000
  Mime-Version: 1.0
  Content-Type: text/plain; charset=&quot;utf-8&quot;
  Subject: ...stripped...
  From: my-website &lt;support@my-website.com&gt;
  To: RECIEVER@gmail.com
  Message-Id: &lt;20130904120442.1488.88532@my-website.com&gt;
  X-Mailgun-Sid: WyI5YmI1OSIsICJqb2Vob3BmK2VlZ2VpN2lkMm9pbW9vYm9vZmFpQGdtYWlsLmNvbSIsICJjMmIzNyJd
  Date: Wed, 04 Sep 2013 12:04:43 +0000
  Sender: support@my-website.com
  Content-Transfer-Encoding: base64
  
  ...email body...
  </code></pre>
  <p>This is the Raw email displayed from an actual mail in a gmail inbox.
  As you can see the Return-Path header contains an email address that ends in <code>@my-website.com</code></p>
  <p>But I have only set up dns records for outgoing email (spf, domainkey, etc).
  Not for incoming email. Meaning, my MX records still point to mailservers somewhere else (In my case google apps).</p>
  <p>How is it possible then that the bounce email arrives at mailgun servers?</p>
  <p>I would have expected to see an email address ending in <code>@some-mailgun-server.com</code> in the <code>Return-Path</code> header!</p>
  <p>I have been using Amazon SES before, and there they had <code>Return-Path</code> header ending in <code>amazonses.com</code></p>
  <p>I asked the mailgun support and got this response:</p>
  <blockquote>
  <p>Nick: your setup is correct, Mailgun will still automatically handle
  the bounces even though your mx records are pointing elsewhere</p>
  </blockquote>
  <p>They just assured me that everything was fine but gave me no explanation (which is okay since their job is not to teach me things I don't know but to deliver reliable email service...)</p>
  <p>So I hope somebody can explain this to me.</p>
  <p>I hope the point is clear, if not please ask and I will try to clarify my question.</p>
  <p>EDIT:</p>
  <p>One theory of me is that the bounce email is indeed sent to google mail servers where it is discarded. However that this is redundant since the error response is also sent to the sending mailserver during the process (when it opens its tcp connection to the target mail server).</p>
  <p>To test this theory and since the Return-Path email is in the form of <code>bounce+SOMETHING@my-website.com</code>, and google delivers all email, regardless of what comes after the <code>+</code> character, to the user in front of it, I went ahead and created the account <code>bounce@my-domain.com</code> on google apps.</p>
  <p>I also tried to send an email to <code>bounce+a801a1.c2b37-RECIEVER=gmail.com@my-website.com</code>.</p>
  <p>It made it through to my inbox.</p>
  <p>Now I expected to receive bounce traffic in my inbox. So I sent an email to an nonexistent hotmail address. I did not receive email on my google apps inbox, and mailgun successfully tracked the bounce.</p>
  <p>So... It appears that it does indeed work. I just don't understand why.</p>
  <p>One more theory I have is that the mailserver to which the bounce email is delivered is never resolved using its MX records. Rather always the delivering server, in this case <code>luna.mailgun.net</code> is chosen.
  The domain ending in the <code>Return-Path</code> address is just the name of the mailbox on the server, but the domain has nothing to do with the server where the mail is actually delivered.</p>
  <p>Then it would also make sense to make it like this since it might improve deliverability if the domains of <code>From</code> and <code>Return-Path</code> address match.</p>
  <p>However this is only a theory. And it would also mean that a mailbox which is able to receive bounces, must be on the same server that is used for sending.</p>
  <p>In other words it would be impossible to have a mailbox to receive bounce email addresses that is hosted somewhere else than the actual server sending the mail. But this sounds strange to me as well...</p>
  <p>I hope somebody can enlighten me.</p>