How to set a Return-Path header for Laravel mail

January 27, 2021

The Return-Path header in an email defines which email address should receive bounces and complaints (such as getting marked as spam). It’s useful to set this header so you can monitor how many complaints you’re getting, and which emails are bouncing.

You can set this header in a Laravel Mailable using the withSwiftMessage() method:

public function build()
    $this->withSwiftMessage(function ($message) {
                ->addTextHeader('Return-Path', '');

    return $this
        // the rest of the normal mailable methods for from, subject, etc

Now, this email will have the Return-Path header defined, and receiving email clients will send a notification email to that address if the email bounces or is marked as spam.