Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ajo_doctorslink's avatar

Error sending email using smtp.google.com

I'm trying to send an email using the standard email feature in Laravel 5.4. I'm using smtp from google to send mails. When working local the email sends without a problem. But when I'm trying to do the same on my hosting I get the following error.

ErrorException in StreamBuffer.php line 94: stream_socket_enable_crypto(): Peer certificate CN=hostname' did not match expected CN=smtp.gmail.com'

My .env file

MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=***** MAIL_PASSWORD=**** MAIL_ENCRYPTION=tls

Thanks in advance.

0 likes
1 reply
KenoKokoro's avatar
Level 13

@Ajo_doctorslink

Try chainging MAIL_DRIVER=mail

Don't forget to clear the config cache before testing it out.

php artisan config:clear
2 likes

Please or to participate in this conversation.