I have this issue and is that I need to set header to a Mail but not via Mail::send()
I need to set the headers inside the Mailable Class that I created with
php artisan make:mail
Thanks a lot.
I'm using Laravel 5.3
You should be able to use the withSwiftMessage
method inside your mailable. You can pass this method a callback which receives the Swift_Message
instance which you can use to set your headers.
In your build
method you could have:
$this->withSwiftMessage(function ($message) {
$headers = $message->getHeaders();
$headers->addTextHeader('header-name', 'optional-value');
});
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With