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

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

    With Laravel 5.6, if you want pass multiple emails with names, you need to pass array of associative arrays. Example pushing multiple recipients into the $to array:

    $to[] = array('email' => $email, 'name' => $name);
    

    Fixed two recipients:

    $to = [['email' => 'user.one@example.com', 'name' => 'User One'], 
           ['email' => 'user.two@example.com', 'name' => 'User Two']];
    

    The 'name' key is not mandatory. You can set it to 'name' => NULL or do not add to the associative array, then only 'email' will be used.

提交回复
热议问题