Search code examples
laravellaravel-5.3mailgun

How to send multiple emails using Mailgun in laravel?


I tried this code:

$message->to(array(
                    '[email protected]',
                    '[email protected]'
                ));

$message->from('[email protected]', 'Recipient Name');
$message->subject('Welcome!');

I get error:

The parameters passed to the API were invalid. Check your inputs! Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in domain settings.


Solution

  • Try the following code

    $receivers = ['[email protected]', '[email protected]'];
    Mail::send('your_theme', [], function($message) use ($receivers)
    {    
        $message->to($receivers)->subject('Welcome!');    
    });
    var_dump( Mail:: failures());
    exit;
    

    This works on my laravel 4.2, not sure about later versions. Source : Laravel Mail::send() sending to multiple to or bcc addresses