Issue
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('iamlegend707083@gmail.com')->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?
Solution
You can add simple array :
$usersArray = ['mail@gmail.com', 'mail2@gmail.com', 'mail3@gmail.com'];
foreach($usersArray as $user){
\Mail::to($user)->send(new \App\Mail\TestMail($details));
echo "Email has been Sent!";
});
}
Answered By - Met Br Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.