I'm getting the following error when trying to connect to SMTP + SSL through PHP using nginx + PHP 5,

Could not connect to smtp host 'ssl://smtp.gmail.com' (5) (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)

In phpinfo I see:

OpenSSL support     disabled (install ext/openssl) 

This leads me to believe I've installed OpenSSL incorrectly.

I've read a bunch of places where I should uncomment the following line:

extension = php_openssl.dll

This line does not exist so I added it to the end of my php.ini to no avail. The php_openssl.dll file does not exist anywhere on my server.


The line you are mentioning indeed does activate the openssl PHP-Extension on Windows Machines - though i doubt you are running nginx on Windows.

extension=openssl.so loads the openssl extension on my Box, you need to have PHP compiled with openssl Support:


or/and advise the Package Management of your Distro to build the Extension at all/correctly.


The php_openssl.dll file does not exist anywhere on my server

Then you need to install it (it also requires a compatible openSSL installation). Peering into my crystal ball I see that you are running on MSWindows - did you use a packaged installation for PHP? If so which one?

The binary distribution from php.net includes the php stub dll - if it's not on your machine you may need to reinstall php. Then install openssl and enable loading of the extension.

Alternatively you could just route the SMTP traffic via stud/stunnel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.