Skip to content
Advertisement

Laravel Mail::send() sending to multiple to or bcc addresses

I can’t seem to successfully send to multiple addresses when using Laravel’s Mail::send() callback, the code does however work when I only specify one recipient.

I’ve tried chaining:

JavaScript

and passing an array:

JavaScript

but neither seem to work and I get failure messages when returning Mail::failures(), a var_dump() of Mail::failures() shows the email addresses that I tried to send to, for example:

JavaScript

Clearly doing something wrong, would appreciate any help as I’m not understanding the API either: http://laravel.com/api/4.2/Illuminate/Mail/Message.html#method_to

I realise I could put the Mail::send() method in a for/foreach loop and Mail::send() for each email address, but this doesn’t appear to me to be the optimal solution, I was hoping I would also be able to ->bcc() to all addresses once everything was working so the recipients wouldn’t see who else the mail is being sent to.

Advertisement

Answer

I’ve tested it using the following code:

JavaScript

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) .

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement