2

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(). 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("[email protected]")
    ->setReplyTo("[email protected]")
    ->send();

1 Answer 1

2

Postmark overrides the Return-Path header in your email with their own address ([email protected], by default). This is how Postmark can keep track of bounces etc.

It's possible to use a custom Return-Path address with Postmark, 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. Postmark even has a guide to do this without any development work, using Zapier.

It's also possible to export bounces as CSV files via the Postmark UI, see this link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.