ronrun
ronrun

Reputation: 1234

Laravel certificate verification errors when sending TLS email

Windows 10, Apache httpd 2.4, PHP 7.1.4, Laravel 5.5
Gmail's less secure is Allowed.


My .env file:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl

Error Message:

Connection could not be established with host smtp.gmail.com


MAIL_PORT=587
MAIL_ENCRYPTION=tls

Error Message:

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

How can I resolve the "certificate verify failed" error?

Upvotes: 3

Views: 3688

Answers (2)

ronrun
ronrun

Reputation: 1234

If your operating system doesn't automatically manage your trusted certificate store:

  1. Download the cURL cacert.pem certificate bundle

  2. Put the cacert.pem bundle somewhere you like; if you have self-signed certificates that need to be accepted, open the bundle in a text editor and add them to the end of the file.

  3. Edit php.ini to reference this file location:

curl.cainfo = D:/Servers/php/sslfiles/cacert.pem
openssl.cafile = D:/Servers/php/sslfiles/cacert.pem
  1. Restart PHP-FPM or your web server, depending on how you are running PHP.

Upvotes: 6

Shahrooz Yousefi Pour
Shahrooz Yousefi Pour

Reputation: 19

When you receive ssl certificate verification error, You can set these two variables in .env file:

MAIL_PORT=587
MAIL_ENCRYPTION=tcp

Upvotes: -1

Related Questions