I'm trying to send an email from Gmail using Laravel from localhost. I'm getting this error: Connection could not be established with host smtp.gmail.com [ #0]
I'm using ssl with port 465. I also tried 587 but it didn't work.
I also tried this but it didn't work. I found a lot of people suffering from the same problems, but the solutions I found didn't work.
Editor's note: disabling SSL verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a Man-in-the-Middle Attack.
Be sure you fully understand the security issues before using this as a solution.
In Laravel project directory, edit config/mail.php
and add the following:
'stream' => [ 'ssl' => [ 'allow_self_signed' => true, 'verify_peer' => false, 'verify_peer_name' => false, ], ]
It worked for me.
Fyi, my SMTP settings are:
MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=465 MAIL_USERNAME=[Full Gmail Address] MAIL_PASSWORD=[Google App Password obtained after two step verification on Google Account Page] MAIL_ENCRYPTION=ssl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With