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


Can not successfully send me to multiple addresses while using Laravel's mail I:: Send a callback, the code works only when I only specify one to the recipient.

I have tried:

  // For example $ emails = array ("myemail1@email.com", "myemail2@email.com"); $ Input = input :: all (); Mail :: ad ('emails.admin-company', array ('body' = & gt; input :: find ('email_bodie')), function ($ message) usage ($ email, $ input) {$ message - & Gt; ('Admin@admin.org', 'administrator') - & gt; Topic ('admin topic'); foreach ($ email as email $ email) {$ message- & gt; to ($ email) ;}});  

and another array is passing:

  // $ email = array for example ("myemail1@email.com", "myemail2 @ email .com "); $ Input = input :: all (); Mail :: ad ('emails.admin-company', array ('body' = & gt; input :: find ('email_bodie')), function ($ message) usage ($ email, $ input) {$ message - & Gt; ('admin@admin.org ',' Admin ') - & gt; Topic (' Admin Subject '); $ Message- & gt; From ($ email);});  

but do not work and mail me: failures (), send a var_dump () mail :: failure () email address, which I tried to send, for example :

  array (2) {[0] = & gt; String (18) "myemail1@email.com" [1] = & gt; String (18) "myemail2@email.com"}  

Obviously something is doing wrong, appreciate any help because I do not understand the API:

I realize that I can send mail :: send for the method / foreach loop and mail :: () for each email address , But it does not appear to be the optimal solution, I was hoping that when everything was working then I would call - & gt; BCC () could also be enabled on all addresses so that the recipient would not know who the mail is

I tested it using the following code:

  $ email = ['myoneemail@esomething.com', 'myother@esomething.com', 'myother2 @ esomething .com ']; Mail: send ('emails.welcome', [], function ($ message) usage ($ email) {$ message- & gt; (email $) - & gt; subject ('this test is an e-mail') ;}); Var_dump (Mail :: Failure ()); Go out;  

Result - Empty AR for failures

But of course you must configure your app / config / mail.php properly. So first make sure that you can only send e-mails to one user and then check your code with multiple users.

In addition to using this simple code, none of my e-mails were distributed to the mail accounts for free, I only received emails from inboxes, which are on my paid hosting accounts So, perhaps they were caught by some filters (this is probably a simple topic / content problem, but I've mentioned this just because you have not received any e-mails)


Comments