php - Laravel 使用 mail::to 发送电子邮件而不查看其他收件人
问题描述
我有一组收件人$this->recipients
,我想向所有收件人发送电子邮件而不显示彼此的电子邮件。目前,它显示电子邮件中的所有收件人。
if (count($this->recipients) > 1) {
Mail::bcc($this->recipients)
->send(new EmailNotificationMailable($this->notificationRequest));
} else {
Mail::to($this->recipients)
->send(new EmailNotificationMailable($this->notificationRequest));
}
我试过这段代码,但是当我用Mail::bcc
电子邮件发送时To
是空的。请为此提供有效的解决方案。我不想循环收件人数组
解决方案
您需要遍历收件人集合:
if(count($this->recipients) > 1)
{
$this->recipients->each(function($recipient)
{
Mail::to(recipient)->bcc($this->recipients)->send(new EmailNotificationMailable($this->notificationRequest));
}
}else{
Mail::to($this->recipients)->send(new EmailNotificationMailable($this->notificationRequest));
}
推荐阅读
- python - Kivy Widget 不动
- excel - 有没有一种通用的方法来处理excel中的可见单元格?
- python - 如何通过mysql python将多个值(列表)插入数据库
- c - C中临时对象的有效类型
- java - 访问不同 fxml 文件中的 ui 元素
- javascript - 如何使用 NodeJs Async 更新数据库中的数组数据?
- azure - 构建管道中的变量替换
- javascript - 我需要使用 javascript 从结果 json 文件中删除不必要的 json 对象
- python - 查找两个列表python中每个单词的频率
- ios - iOS - 因横向和纵向特征而异