我有一組收件人$this->recipients,我想向所有收件人發(fā)送電子郵件而不顯示彼此的電子郵件。目前,它顯示電子郵件中的所有收件人。 if (count($this->recipients) > 1) { Mail::bcc($this->recipients) ->send(new EmailNotificationMailable($this->notificationRequest)); } else { Mail::to($this->recipients) ->send(new EmailNotificationMailable($this->notificationRequest)); }我試過(guò)這段代碼,但是當(dāng)我用Mail::bcc電子郵件發(fā)送時(shí)To是空的。請(qǐng)為此提供有效的解決方案。我不想循環(huán)收件人數(shù)組
2 回答

阿晨1998
TA貢獻(xiàn)2037條經(jīng)驗(yàn) 獲得超6個(gè)贊
您需要遍歷收件人集合:
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貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊
使用這樣的東西:
Mail::to(array_pop($this->recipients))->bcc($this->recipients)
這會(huì)將recipients
數(shù)組中的最后一個(gè)條目設(shè)置為郵件接收者,并且所有其他地址都將通過(guò)密件抄送包括在內(nèi)。
- 2 回答
- 0 關(guān)注
- 276 瀏覽
添加回答
舉報(bào)
0/150
提交
取消