我有一組收件人$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 關注
- 292 瀏覽
添加回答
舉報
0/150
提交
取消