简体   繁体   English

Zend 邮件 Gmail SMTP

[英]Zend Mail Gmail SMTP

Hi I'm trying to send some emails via gmail from the Zend_Mail module.嗨,我正在尝试从 Zend_Mail 模块通过 gmail 发送一些电子邮件。 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警告:stream_socket_enable_crypto() [streams.crypto]:此流不支持第 206 行 /library/Zend/Mail/Protocol/Smtp.php 中的 SSL/crypto Unable to connect via TLS

I tried telling my hosting provider to enable the openssl.dll in phi.ini我试着告诉我的托管服务提供商在 phi.ini 中启用 openssl.dll

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.但是他们说这不是必需的,因为服务器在 Linux 中并且不需要启用 openssl.dll 来使用 TLS 或 SSL。

Is my hosting provider wrong or I'm I doing something wrong in my code.是我的托管服务提供商错了,还是我的代码做错了。

Thanks in advance提前致谢

Fabian法比安

openssl.dll is the windows openssl extension. openssl.dll 是 windows openssl 扩展。

On Linux you need to compile PHP with OpenSSL support.在 Linux 上,您需要使用 OpenSSL 支持编译 PHP。 http://www.php.net/manual/en/openssl.installation.php http://www.php.net/manual/en/openssl.installation.php

You need OpenSSL for PHP sockets and stream functions to use TLS.您需要针对 PHP 套接字和流函数的 OpenSSL 才能使用 TLS。 Zend uses these functions and thus require the same. Zend 使用这些功能,因此需要相同的功能。

I was having a similar problem here is what worked;我在这里遇到了类似的问题,这是有效的; Using Zend mail transport and yahoo smtp:使用 Zend 邮件传输和 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 to; $transport = new Zend_Mail_Transport_Sendmail('-fsupport@website.com',$mailhost, $mailconfig);

works as expected...按预期工作...

使用Zend_Mail::setDefaultTransport方法很舒服

尝试将 ssl:// 设置为主机名的前缀并使用 465 作为端口。

after hours of troubleshooting, changing 'ssl' => 'tls' to 'ssl' => 'ssl'经过数小时的故障排除,将 'ssl' => 'tls' 更改为 'ssl' => 'ssl'

worked for me.为我工作。 It was working fine in previous server.它在以前的服务器中运行良好。 After moving to new server, tls error statrted.移动到新服务器后,tls 错误 statrted。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM