Zend Mail Gmail SMTP

2019-01-18 06:58发布

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' => 'webmaster@mydomain.com',
    '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

4条回答
乱世女痞
2楼-- · 2019-01-18 07:17

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.

查看更多
时光不老,我们不散
3楼-- · 2019-01-18 07:18

It's very comfortably to use Zend_Mail::setDefaultTransport method

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-18 07:21

I was having a similar problem here is what worked; Using Zend mail transport and yahoo smtp:

$mailhost= 'smtp.example.com';
$mailconfig = array(
    'auth'     => 'login',
    'username' => 'me@example.com',
    'password' => 'topsecret',
    'port'     => '465',
    'ssl'      => 'ssl'
);
$transport = new Zend_Mail_Smtp($mailhost, $mailconfig);
Zend_Mail::setDefaultTransport($transport);

This produced an error: "Permission denied" and no mail was sent. After three weeks of trying all solutions I could find the one that worked was changing: $transport to; $transport = new Zend_Mail_Transport_Sendmail('-fsupport@website.com',$mailhost, $mailconfig);

works as expected...

查看更多
贪生不怕死
5楼-- · 2019-01-18 07:26

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

查看更多
登录 后发表回答