我有一组收件人$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是空的。请为此提供有效的解决方案。我不想循环收件人数组
2 回答
阿晨1998
TA贡献2037条经验 获得超6个赞
您需要遍历收件人集合:
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));
}
GCT1015
TA贡献1827条经验 获得超4个赞
使用这样的东西:
Mail::to(array_pop($this->recipients))->bcc($this->recipients)
这会将recipients
数组中的最后一个条目设置为邮件接收者,并且所有其他地址都将通过密件抄送包括在内。
- 2 回答
- 0 关注
- 238 浏览
添加回答
举报
0/150
提交
取消