Adding headers to email sent as a Laravel Notification

后端 未结 3 1995
无人及你
无人及你 2021-01-18 20:13

Someone knows how to add headers to emails sent through Laravel Notification System?

I am not talking about Mailable classes where I can set header through the

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 20:21

    Actually I've found 2 ways to append headers.

    When the notification is sent via mail channel an Illuminate\Mail\Events\MessageSending event is fired.

    Append a listener to it. In handle() you will get the Swift_Message object.

    Or in the AppServiceProvider's register() method override the MailChannel with your own and append the header in the send() method.

    $this->app->bind(
        \Illuminate\Notifications\Channels\MailChannel::class,
        MyMailChannel::class
    );
    

提交回复
热议问题