Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending email to multiple cc recipients in Laravel 5.4

Tags:

php

email

laravel

I have a function that sends an email like this:

Mail::to($email)
->cc($arraywithemails)
->send(new document());

How do I send the email to multiple cc users? I have checked the official documentation but there is no clue there.

like image 917
prgrm Avatar asked May 03 '17 14:05

prgrm


People also ask

How do I add multiple recipients to CC?

You can add multiple Cc and Bcc by separating them with comma. Add the recipients in a column called "cc" for Cc recipients and "bcc" for Bcc recipients. To add multiple recipients, Cc or Bcc, just separate them with comma.


2 Answers

The setAdress() function in Mailable allow you to give an array as argument :

Mailable.php

So You should be able to use the function by passing an array as your argument

Mail::to($email)
    ->cc(['[email protected]','[email protected]'])
    ->send(new document());
like image 50
Mathieu Ferre Avatar answered Sep 19 '22 21:09

Mathieu Ferre


That should work. From the offical Laravel documentation:

Mail::to($request->user())
    ->cc($moreUsers)
    ->bcc($evenMoreUsers)
    ->send(new OrderShipped($order));
like image 37
Mozammil Avatar answered Sep 18 '22 21:09

Mozammil