php Laravel 邮件密件抄送

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26774204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:03:24  来源:igfitidea点击:

Laravel mail bcc

phpemaillaravellaravel-4

提问by Ivan Dokov

I am using the default Laravel Mailclass to send emails.

我使用默认的 LaravelMail类来发送电子邮件。

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('[email protected]', 'My Company');

        $message->to($toEmail, $toName);
        $message->bcc('[email protected]');

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

回答by Ivan Dokov

I have found the problem.
I didn't use the correct parameters for $message->bcc('[email protected]');

我找到了问题所在。
我没有使用正确的参数$message->bcc('[email protected]');

I had to write email AND name: $message->bcc('[email protected]', 'My Name');
The same way as I use $message->to($toEmail, $toName);

我必须写电子邮件和姓名:$message->bcc('[email protected]', 'My Name');
与我使用的方式相同$message->to($toEmail, $toName);

回答by Sr.PEDRO

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

正如 Ivan Dokov 所说,您需要将电子邮件和姓名传递给 bcc 函数。你也可以通过这样做来缩短你的代码

  function($message) use ($toEmail, $toName) {
        $message->from('[email protected]', 'My Company')
                ->to($toEmail, $toName)
                ->bcc('[email protected]','My bcc Name')
                ->subject('New order');
    }