亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Laravel 使用 mail::to 發送電子郵件而不查看其他收件人

Laravel 使用 mail::to 發送電子郵件而不查看其他收件人

PHP
慕容3067478 2022-07-16 16:00:27
我有一組收件人$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));

}


查看完整回答
反對 回復 2022-07-16
?
GCT1015

TA貢獻1827條經驗 獲得超4個贊

使用這樣的東西:

Mail::to(array_pop($this->recipients))->bcc($this->recipients)

這會將recipients數組中的最后一個條目設置為郵件接收者,并且所有其他地址都將通過密件抄送包括在內。


查看完整回答
反對 回復 2022-07-16
  • 2 回答
  • 0 關注
  • 292 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號