Laravel Mail::send() sending to multiple to or bcc addresses
I've tested it using the following code:
$emails = ['myoneemail@esomething.com', 'myother@esomething.com','myother2@esomething.com'];
Mail::send('emails.welcome', [], function($message) use ($emails)
{
$message->to($emails)->subject('This is test e-mail');
});
var_dump( Mail:: failures());
exit;
Result - empty array for failures.
But of course you need to configure your app/config/mail.php
properly. So first make sure you can send e-mail just to one user and then test your code with many users.
Moreover using this simple code none of my e-mails were delivered to free mail accounts, I got only emails to inboxes that I have on my paid hosting accounts, so probably they were caught by some filters (it's maybe simple topic/content issue but I mentioned it just in case you haven't received some of e-mails) .
How to send emails to multiple users using Laravel 7 Mail?
You can add simple array :
$usersArray = ['mail@gmail.com', 'mail2@gmail.com', 'mail3@gmail.com'];
foreach($usersArray as $user){
\Mail::to($user)->send(new \App\Mail\TestMail($details));
echo "Email has been Sent!";
});
}
Sending email to multiple recipients using Laravel
are you using queue jobs? you must use it otherwise your server may not respond for multiple email. second you are sending multiple emails at the same time may be you should try this.
$mails = User::select('users.name','users.staffid','users.email')->get();
foreach($mails as $dat)
{
Mail::send('email.sendReminder', ["data1"=>$dat], function($message) use ($dat) {
$message->from('test@gmail.com', 'Test Reminder');
$message->to($dat['email']);
$message->subject('Reminder');
});
}
Sending email to multiple cc recipients in Laravel 5.4
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(['name1@example.com','name2@example.com'])
->send(new document());
How to send Multiple mail Using laravel?
You can use mailable and send mail to multiple recipients adding them in the loop. You can refer more in the documentation link.
https://laravel.com/docs/8.x/mail
foreach (['taylor@example.com', 'dries@example.com'] as $recipient) {
Mail::to($recipient)->send(new OrderShipped($order));
}
Laravel 5.3 send Mail to multiple email-adresses
I think it should work, when you pass an array. Check the reference:
https://laravel.com/api/5.3/Illuminate/Mail/Message.html#method_to
The first parameter can be an array. Try it.
Related Topics
Seamless Way to Check If User Likes Page
Check If String Contains a Value in Array
How to Write Cdata Using Simplexmlelement
How to Use Spl_Autoload() Instead of _Autoload()
How to Delete an Object's Property in PHP
PHP Header(Location: ...): Force Url Change in Address Bar
What Is a Unix Timestamp and Why Use It
How to Read Only 5 Last Line of the Text File in PHP
Generating Xml Document in PHP (Escape Characters)
How to Modify Xml File Using PHP
Leverage Browser Caching for 3Rd Party Js
New Limit Within PHP: 1000 Fields Per Post. Does Someone Know, If the Number Can Be Influenced
Get the Latest File Addition in a Directory
Manipulate an Archive in Memory with PHP (Without Creating a Temporary File on Disk)