Answers.Body: <p>Postmark overrides the Return-Path header in your email with their own address (<code>pm_bounces@pm.mtasv.net</code>, by default). This is how Postmark can keep track of bounces etc.</p>
  <p>It's possible to <a href="https://postmarkapp.com/support/article/910-how-do-i-add-a-custom-return-path" rel="nofollow noreferrer">use a custom Return-Path address with Postmark</a>, but they still require that the custom Return-Path domain is a CNAME alias pointing to Postmark (for the same reason; they need to keep track of the bounces and etc) – so I don't think you'll be able to actually deliver the bounced emails to your own email address.</p>
  <p>To actually track/get notified when Postmark emails bounce, you can use <a href="https://postmarkapp.com/support/article/1106-how-to-set-up-a-bounce-webhook" rel="nofollow noreferrer">their bounce webhook</a>. Postmark even has <a href="https://postmarkapp.com/support/article/1127-using-zapier-webhooks-to-notify-senders-of-bounces" rel="nofollow noreferrer">a guide to do this without any development work, using Zapier</a>.</p>
  <p>It's also possible to export bounces as CSV files via the Postmark UI, see <a href="https://postmarkapp.com/support/article/881-can-i-export-a-list-of-all-bounces" rel="nofollow noreferrer">this link</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-04T19:26:37.557Z
Answers.LastActivityDate: 2023-02-04T19:26:37.557Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I am using Craft 3 and Postmark SMTP to send emails to users. Users are activated manually because of a necessary user verification process, so we are not using the built in user activation link functionality to verify email addresses.</p>
  <p>We need to be notified if emails bounce back, so we are using <a href="https://docs.craftcms.com/api/v3/craft-mail-message.html#public-properties" rel="nofollow noreferrer">setReturnPath()</a>.
  The following code works if the user email is valid, but if it's invalid, nothing is sent to the return path email and there's no way of knowing the email bounced back.</p>
  <p>Why isn't setReturnPath() working as expected?</p>
  <pre><code>Craft::$app
      -&gt;getMailer()
      -&gt;composeFromKey('follow_up_email')
      -&gt;setTo($user)
      -&gt;setReturnPath(&quot;myemail@gmail.com&quot;)
      -&gt;setReplyTo(&quot;myemail@gmail.com&quot;)
      -&gt;send();
  </code></pre>
  
Tags: <emails><smtp>
Title: SetReturnPath not successfully bouncing emails back
ThreadText: # SetReturnPath not successfully bouncing emails back
  
  (Asked by: username_0 on 2023-02-03)
  
  I am using Craft 3 and Postmark SMTP to send emails to users. Users are activated manually because of a necessary user verification process, so we are not using the built in user activation link functionality to verify email addresses.
  
  We need to be notified if emails bounce back, so we are using [setReturnPath()](https://docs.craftcms.com/api/v3/craft-mail-message.html#public-properties).
  The following code works if the user email is valid, but if it's invalid, nothing is sent to the return path email and there's no way of knowing the email bounced back.
  
  Why isn't setReturnPath() working as expected?
  
  ```
  Craft::$app
      ->getMailer()
      ->composeFromKey('follow_up_email')
      ->setTo($user)
      ->setReturnPath("myemail@gmail.com")
      ->setReplyTo("myemail@gmail.com")
      ->send();
  
  ```
  
  **Tags:** emails, smtp
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-02-04. Score: 2 | Accepted answer
  
  Postmark overrides the Return-Path header in your email with their own address (`pm_bounces@pm.mtasv.net`, by default). This is how Postmark can keep track of bounces etc.
  
  It's possible to [use a custom Return-Path address with Postmark](https://postmarkapp.com/support/article/910-how-do-i-add-a-custom-return-path), but they still require that the custom Return-Path domain is a CNAME alias pointing to Postmark (for the same reason; they need to keep track of the bounces and etc) – so I don't think you'll be able to actually deliver the bounced emails to your own email address.
  
  To actually track/get notified when Postmark emails bounce, you can use [their bounce webhook](https://postmarkapp.com/support/article/1106-how-to-set-up-a-bounce-webhook). Postmark even has [a guide to do this without any development work, using Zapier](https://postmarkapp.com/support/article/1127-using-zapier-webhooks-to-notify-senders-of-bounces).
  
  It's also possible to export bounces as CSV files via the Postmark UI, see [this link](https://postmarkapp.com/support/article/881-can-i-export-a-list-of-all-bounces).
  
  
  ---
  
  