//mail
$result = Mail::send('site.email', ['data'=>$data], function ($m) use ($data) {
$m->from('minibaev2001@yandex.ru', $data['name']);
$m->to('minibaev2001@yandex.ru', 'Mr.Admin')->subject('Laravel');
});
if ($result) {
return redirect()->route('home')->with('status', 'Email is send');
}
if( count(Mail::failures()) > 0 ) {
echo "There was one or more failures. They were: <br />";
foreach(Mail::failures as $email_address) {
echo " - $email_address <br />";
}
}
// check for failures
if (Mail::failures()) {
return redirect()->back()->with('status', 'Email not send');
}
// otherwise everything is okay ...
return redirect()->route('home')->with('status', 'Email is send');