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

前端 未结 10 1212
梦谈多话
梦谈多话 2020-11-28 05:26

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 sp

10条回答
  •  孤城傲影
    2020-11-28 06:05

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

提交回复
热议问题