Zend 邮件 Gmail SMTP

2021-12-29 00:00:00 email ssl gmail php zend-framework

我正在尝试从 Zend_Mail 模块通过 gmail 发送一些电子邮件.这是我的代码:

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);

错误:

警告:stream_socket_enable_crypto() [streams.crypto]:该流在第 206 行的/library/Zend/Mail/Protocol/Smtp.php 中不支持 SSL/crypto无法通过 TLS 连接

我尝试告诉我的托管服务提供商在 phi.ini 中启用 openssl.dll

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

但他们说这不是必需的,因为服务器在 Linux 中并且不需要启用 openssl.dll 来使用 TLS 或 SSL.

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.

提前致谢

费边

推荐答案

openssl.dll 是 windows openssl 扩展.

openssl.dll is the windows openssl extension.

在 Linux 上,您需要使用 OpenSSL 支持编译 PHP.http://www.php.net/manual/en/openssl.installation.php

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

您需要 OpenSSL for PHP 套接字和流函数才能使用 TLS.Zend 使用这些函数,因此需要相同的函数.

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

相关文章