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

前端 未结 10 1227
梦谈多话
梦谈多话 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:12

    the accepted answer does not work any longer with laravel 5.3 because mailable tries to access ->email and results in

    ErrorException in Mailable.php line 376: Trying to get property of non-object

    a working code for laravel 5.3 is this:

    $users_temp = explode(',', 'first@example.com,second@example.com');
        $users = [];
        foreach($users_temp as $key => $ut){
          $ua = [];
          $ua['email'] = $ut;
          $ua['name'] = 'test';
          $users[$key] = (object)$ua;
        }
     Mail::to($users)->send(new OrderAdminSendInvoice($o));
    

提交回复
热议问题