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

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

    If you want to send emails simultaneously to all the admins, you can do something like this:

    In your .env file add all the emails as comma separated values:

    ADMIN_EMAILS=admin1@site.com,admin2@site.com,admin3@site.com
    

    so when you going to send the email just do this (yes! the 'to' method of message builder instance accepts an array):

    So,

    $to = explode(',', env('ADMIN_EMAILS'));
    

    and...

    $message->to($to);
    

    will now send the mail to all the admins.

提交回复
热议问题