如何隐藏多个收件人电子邮件地址Laravel发送邮件

时间:2019-03-01 21:21:09

标签: php laravel email

我使用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  !!');
       });

1 个答案:

答案 0 :(得分:0)

Laravel在构造上支持以下类型,可能会帮助您(请参阅https://laravel.com/docs/5.7/mail#sending-mail)...

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

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