This is my code which sends an email to a single address:
Route::get('/send-mail', function () {
$details = [
'title' => 'Mail From KN7',
'body' => 'Email test in Laravel SMTP'
];
\Mail::to('[email protected]')->send(new \App\Mail\TestMail($details));
echo "Email has been Sent!";
});
Is there any way to change this code so I can send the same email to multiple email addresses?
Mail::to()in a loop of some kind (like looping over Users/email addresses you want to send to), or see if multiple addresses works (likeMail::to(['address1', 'address2'])), or use->cc()or->bcc()with the same logic.Mail::towould need to be sent as an array, so just needs the braces.