Hello, I am trying to config my contact form to send email using google smtp but no email received.
The .env is like below: MAIL_DRIVER=mail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xyz@gmail.com
MAIL_PASSWORD=xyz
MAIL_ENCRYPTION=tls
the code at controller is like:
try {
Mail::send('email.newEmail', $data, function ($message){
$message->to('myemail@yahoo.com', 'myEmail')
->subject('New email from your website');
$message->from('xyz@gmail.com ', 'xyz');
});
return view('contact-us', ['msg' => 'Email was sent successfully! We will contact you as soon as possible.', 'msgSuccess' => true]);
}catch (Exception $ex) {
return view('contact-us', ['msg' => 'Email failed to send, please try again later !', 'msgSuccess' => false]);
}
and it shows that email was sent successfully but no email archive at my inbox(or spam).
I have try to change host and the email is ok(and when i try from localhost it's ok).
I am hosting my site on VPS(contabo, operating system: Ubuntu 16.04)
Can someone help me?
Thank you
Hello andixhafa!
If email is sent properly and working on localhost, probably you have problems with google settings.
Check these settings in your gmail account:
I hope that problem is there and will be solved soon :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community