【问题标题】:How to hide multiple recipient email addresses laravel send mail如何隐藏多个收件人电子邮件地址 laravel 发送邮件
【发布时间】:2019-07-23 22:47:15
【问题描述】:

我使用 laravel Mail 功能将 html 邮件发送到多个电子邮件 我创建了电子邮件数组,消息成功发送给所有用户,但在电子邮件消息的顶部显示所有电子邮件地址用户, 如何解决此问题如何在电子邮件数组中使用ccbcc

 $product = Product::find($request->product_id)->get()->first();
     $emailUsers = User::select('email')->pluck('email')->toArray();
     $emailSubscribers = NewsLetter::select('email')->pluck('email')->toArray();
     $emails =array_unique(array_merge($emailUsers,$emailSubscribers), SORT_REGULAR);
     $end_at = Carbon::parse($request->end_at, 'UTC')->format('d/m/Y');
       $data = array(
          'name' =>$request->name,
          'product_name' =>$product->name,
          'product_img' =>$product->poster,
          'discount' =>$request->discount,
          'price_with_discount' =>$request->price_with_discount,
          'price_without_discount' =>$product->price,
          'start_at' =>$request->start_at,
          'end_at' =>$end_at,
          'description' =>$request->description
       );
       Mail::send('front-office.mails.promotion-letters.mail-promo', $data, function ($message) use($request,$emails) {
            $message->from('team@testemail.com','test');
            $message->to($emails)->subject
              ('Nouvelles promotion  !!');
       });

【问题讨论】:

  • 使用 foreach 循环分别发送给每个用户。

标签: php laravel email


【解决方案1】:

Laravel 确实支持以下可能对您有所帮助的构造类型(请参阅https://laravel.com/docs/5.7/mail#sending-mail)...

Mail::to($request->user())
    ->cc($moreUsers)
    ->bcc($evenMoreUsers)
    ->send(new OrderShipped($order));

而 bcc() 部分将隐藏收件人的电子邮件。

【讨论】:

  • 但我想发送两个不同表用户和订阅者的电子邮件
  • 您可以在 to() 或 cc() 中添加可见的电子邮件,在 bcc() 中添加隐藏的电子邮件地址。除非我不明白您所说的“发送两个不同表格的电子邮件”是什么意思
  • 我收到从两个表发送的电子邮件,我使用 array_merge 让一个数组包含所有电子邮件
  • 在这种情况下,您如何知道要隐藏哪些电子邮件地址?我不明白。
  • 这是不可能的,在您的情况下,您将不得不遍历每个地址并单独发送邮件。如果您想一次性发送所有邮件,密件抄送是唯一的选择
猜你喜欢
  • 1970-01-01
  • 2016-01-21
  • 2020-12-01
  • 1970-01-01
  • 2019-04-22
  • 1970-01-01
  • 2017-04-02
  • 2011-05-21
  • 2020-11-28
相关资源
最近更新 更多