nameless nameless - 1 year ago 121
PHP Question

Laravel 5.3 send Mail to multiple email-adresses

I'm using Laravel 5.3 and trying to send a newsletter Mail to specific mail adresses.

Currently I do the following:

$newsletterMailAdresses = Newsletter::where('user_id', $userID)->pluck('mailAdress');

This returns an array of email-adresses, to which the emails shouuld be sent.

What I then (normally) use to send mails is:

Mail::to("someMailAdress")->send(new newsletterMail($newsletterText));

I thought about just passing that array into the
function but I'm quite sure it won't work.... What you propably could do, is a foreach with every mail adress and send the mails, but is this the way how this should be done or is there a better way?

PS: I know that thread but its about Laravel 4, so there are many things changed.

Answer Source

I think it should work, when you pass an array. Check the reference:

The first parameter can be an array. Try it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download