简体   繁体   English

使用gmail SMTP的Zend Mail

[英]Zend Mail using gmail SMTP

There are like 1000 posts on this, but somehow I cant get things to work. 大概有1000个帖子,但是我不知怎么做。 I use 我用

$config = array('ssl' => 'tls',
            'auth' => 'login',
                'port' => 587,
                'username' => 'myusername@gmail.com',
                'password' => 'mypassword');

$tr = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

and get a 并得到一个

Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message 'Unable to connect via TLS'

Using 使用

$config = array('ssl' => 'ssl',
                'auth' => 'login',
                'port' => 465,
                'username' => 'myusername@gmail.com',
                'password' => 'mypassword');

$tr = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

I am getting 我正进入(状态

Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message 'Could not open socket'

Btw, I am using xampp 1.7.7. 顺便说一句,我正在使用xampp 1.7.7。 Any help anyone? 任何人有帮助吗?

I'm pretty sure Gmail doesn't allow SSL/TLS. 我敢肯定,Gmail不允许SSL / TLS。 If you remove that line I believe the config above should work, assuming correct username and password. 如果您删除该行,我相信上面的配置可以正常工作,并假设用户名和密码正确。

Find following in the php.ini file 在php.ini文件中找到以下内容

;extension=php_openssl.dll
//remove the semicolon in front, save and restart apache, then passed.

Hope it works for you 希望这对你有用

Try to use this config array (it works for me): 尝试使用此配置数组(适用于我):

$config = array(
   'ssl' => 'tls',
   'auth' => 'login',
   'port' => 25,
   'username' => 'myusername@gmail.com',
   'password' => 'mypassword');

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

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