Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.5: Can't sent email via google (SSL operation failed) [duplicate]

Tags:

php

laravel

I saw the bellow settings for .env in answers on similar questions:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=somePassword1234
MAIL_ENCRYPTION=tls

However, nothing works. With, tls encryption, I got error

stream_socket_enable_crypto(): SSL operation failed with code 1. 
OpenSSL Error messages: error:14090086:SSL routines:
ssl3_get_server_certificate:certificate verify failed

With ssl encryption, I got error:

Swift_TransportException
Expected response code 220 but got code "", with message ""
like image 979
Takeshi Tokugawa YD Avatar asked Feb 03 '18 00:02

Takeshi Tokugawa YD


1 Answers

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 Gmail, 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.

You must disable signing the letter with a certificate in config mail file: mail.php

return [ 
....
'stream' => [
    'ssl' => [
        'allow_self_signed' => true,
        'verify_peer' => false,
        'verify_peer_name' => false,
    ],
],
....
];
like image 95
Ilya Yaremchuk Avatar answered Oct 02 '22 15:10

Ilya Yaremchuk