Support the ongoing development of Laravel.io →
Configuration Mail Installation
Last updated 2 years ago.
0

Laravel will fire an event right before sending an email: https://laravel.com/docs/5.3/mail#events You can listen for this event and add your headers in the event listeners handle method.

public function handle(MessageSending $event)
    {
        $headers = $event->message->getHeaders();
        $headers->addTextHeader('x-mailgun-native-send', true);
    }
0

You can just actually use the withSwiftMessage method of Mailable class by passing a callback function to it. Inside your extending-mailable class, try this:

$this->withSwiftMessage(function ($message) {
     $headers = $message->getHeaders();
     $headers->addTextHeader('x-mailgun-native-send', true);
});
Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.