3 years ago

How to add custom headers to Notification emails?

Posted 3 years ago by squibby

Since upgrading to Laravel 5.4 I have been making use of notifications. I send some emails via mailgun and previously added a custom header so I could receive webhooks from mailgun and track mail delivery etc.

I would do something like below:

Mail::send('emails.broadcast', array('recipient' => $this->recipient , 'broadcast' => $this->broadcast), function($message) use ($data) {
    $message->getHeaders()->addTextHeader('recipient_token', $data['token']);

So.. how can I add the custom header I need to send in the email? I don't want to send the header in all emails, just some specific emails from my app.


Please sign in or create an account to participate in this conversation.