Laravel mail bcc

时光毁灭记忆、已成空白 提交于 2019-12-05 14:57:54

问题


I am using the default Laravel Mail class to send emails.

I am trying to add bcc to myself, but when I add a bcc the email is not send at all.
Here is my code:

Mail::send(
    'emails.order.order',
    array(
        'dateTime'  => $dateTime,
        'items'     => $items
    ),
    function($message) use ($toEmail, $toName) {
        $message->from('my@email.com', 'My Company');

        $message->to($toEmail, $toName);
        $message->bcc('mybcc@email.com');

        $message->subject('New order');
    }
);

回答1:


I have found the problem.
I didn't use the correct parameters for $message->bcc('mybcc@email.com');

I had to write email AND name: $message->bcc('mybcc@email.com', 'My Name');
The same way as I use $message->to($toEmail, $toName);




回答2:


As Ivan Dokov said, you need to pass the email and name to the bcc function. You could also shorten your code by doing this

  function($message) use ($toEmail, $toName) {
        $message->from('my@email.com', 'My Company')
                ->to($toEmail, $toName)
                ->bcc('mybcc@email.com','My bcc Name')
                ->subject('New order');
    }


来源:https://stackoverflow.com/questions/26774204/laravel-mail-bcc

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