Add default mail headers in Laravel 5.2

前端 未结 1 1647
南笙
南笙 2021-01-26 07:52

I need to send a mail header \"x-mailgun-native-send: true\" to all my mails so they wont get rejected by receivers.

Is it possible to set default mail headers in Larav

1条回答
  •  失恋的感觉
    2021-01-26 08:17

    I found at 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 讨论(0)
提交回复
热议问题