I am using windows machine and trying to send Emails upon user registration in Laravel. Following is my code. Am new to laravel and i don't know how to use it.
First i run flowing command
php artisan make:mail WelcomeMail
Following is the code in Registration controller
public function storeUsers(Request $request)
{
$postdata = $request->all();
$user = new User;
$hashedRandomPassword = Hash::make('password', [
'rounds' => 12
]);
$user = new User;
$user->name=$postdata['user_name'];
$user->email=$postdata['email'];
$user->password= $hashedRandomPassword;
$user->save();
Mail::to($postdata['email'])->send(new WelcomeMail($user));
// return $user;
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 />";
}
} else {
echo "No errors, all sent successfully!";
}
exit();
return redirect('users');
}
I have also configured smtp settings in both ENV
file and config->mail.php file
in laravel.
What is the issue?When i tired to send emails its always generating There was one or more failures
error section i echoed in code