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);
}
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);
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community