views:

3555

answers:

3

Hi I'm trying to send some emails via gmail from the Zend_Mail module. This is my code:

$config = array(
    'ssl' => 'tls',
    'port' => 587,
    'auth' => 'login',
    'username' => '[email protected]',
    'password' => 'password'
);
$smtpConnection = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

Error:

Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in /library/Zend/Mail/Protocol/Smtp.php on line 206 Unable to connect via TLS

I tried telling my hosting provider to enable the openssl.dll in phi.ini

But they say that isn't necessary since the server is in Linux and it doesn't need to enable the openssl.dll to work with TLS or SSL.

Is my hosting provider wrong or I'm I doing something wrong in my code.

Thanks in advance

Fabian

A: 

Try setting ssl:// as prefix for the hostname and use 465 as port.

Basher
Still getting the same error. I have smtp.server = ssl://smtp.gmail.comand port 465
+4  A: 

openssl.dll is the windows openssl extension.

On Linux you need to compile PHP with OpenSSL support. http://www.php.net/manual/en/openssl.installation.php

You need OpenSSL for PHP sockets and stream functions to use TLS. Zend uses these functions and thus require the same.

bucabay
How would I know in phpinfo if Openssl is enabled? All I see is this OpenSSL/0.9.8b in the apache2handler
You actually need two things, OpenSSL and TLS should be registered as a stream/socket transport. This should be found under: Registered Stream Socket TransportsThe OpenSSL should be found under it's own header since it is an enabled extension. The apache2handler shows the apache config, not PHP's. So you do have OpenSSL compiled on your server and apache configured to use it, but you probably don't have the OpenSSL PHP extensions compiled with PHP. Search your PHP.ini for OpenSSL and see if you find it.
bucabay
Yeah I only have: Registered Stream Socket Transports tcp, udp, unix, udg and no header for the OpenSSL.SO I guess the problem was all on my hosting provider side.thank you very much for your help
Yeah, you'll have to ask your host to recompile PHP with OpenSSL support. OpenSSL is a bit of a pain since PHP can't load the extension at runtime, it needs it compiled with the binary.
bucabay