Symptoms
Unable to connect to SMTP server using PHP and OpenSSL. The following related error messages may appear as part of troubleshooting output:
PHP Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed PHP Warning: fsockopen(): Failed to enable crypto PHP Warning: fsockopen(): unable to connect to ssl PHP User Warning: Unable to connect to SMTP server
Solution
You are missing Certification Authority (CA) files on your system or you have provided an incorrect path to Certification Authority (CA) files. If you did not provide a custom path to CA files within php.ini
file PHP looks for a default system CA root certificate bundle. If CA root certificate bundle is missing you get the above error message. The solution is to install Certification Authority (CA) bundle:
DEBIAN/UBUNTU: # apt-get install ca-certificates FEDORA: # dnf install ca-certificates.noarch CENTOS/REDHAT # yum install ca-certificates.noarch
Another alternative is to provide a custom path to Certification Authority (CA) bundle within php.ini
configuration file using openssl.cafile
and openssl.capath
directives.