Add headers in mail function laravel 5

梦想的初衷 提交于 2021-02-08 21:30:11

问题


I am updating code from laravel 4 to laravel 5

In laravel 4 there is mail functionality implemented with some code like below

Mail::send('emailtemplate.sample', $content_data, function ($message) use ($to_mail, $email_data, $from_name) {
            $message->from('admin@domain.com', 'admin')->to($to_mail)->subject($email_data->subject);                
            $headers = $message->getHeaders();
            $headers->addTextHeader('X-MC-PreserveRecipients', 'false');
        });

I don't know how to replace $headers = $message->getHeaders(); and $headers->addTextHeader('X-MC-PreserveRecipients', 'false'); in laravel 5 mail functionality

If anyone knows, then please suggest


回答1:


As jszobody mentioned,

The getHeaders() method is being called on Swift_Message which isn't part of Laravel, it's a third-party component. So even though Laravel 5 has changed, Swift hasn't and should continue working like before.



来源:https://stackoverflow.com/questions/29098301/add-headers-in-mail-function-laravel-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!