本文介绍了Swift_TransportExceptionConnection无法与主机smtp.gmail.com建立的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
试图在php中发送电子邮件。 运输:smtp
主机:smtp.gmail.com
用户名:[email protected]
密码:密码
端口:587
加密:ssl
已尝试的选项:
- 尝试了端口(22,465,587)和加密(无加密, SSL,TLS)
- 允许访问安全性较低的应用程序,并关闭两种验证方式。 $ b
并尝试使用上面的主机名称和ips。
-
测试过的mailtrap.io及其正常工作! (在mailtrap收件箱中接收电子邮件,所以代码中没有问题)
-
我在另一个.net应用程序中使用相同的Gmail帐户它的工作很好。
还有什么可以尝试的?
$ b $在 streamBuffer.php
中添加了这一行,它工作正常! $ options = array_merge($ options,array('ssl'=> array('allow_self_signed'=> true,'verify_peer'=> false) ));
Trying to send email in php.
transport: smtp
host: smtp.gmail.com
username: [email protected]
password: password
port: 587
encryption: ssl
Options already tried:
- Tried all combinations of port (22, 465, 587) and encryption (No encryption, SSL, TLS)
- Allow access to less secure apps is on and two ways authentication is off.
checked host details:
and tried with above host name and ips.
Tested mailtrap.io and its working fine! (receiving email in mailtrap inbox, so no issue in code)
I'm using same gmail account in another .net application and its working fine over there.
What could be the option left to try?
解决方案
Added this line in streamBuffer.php
and it worked!
$options = array_merge($options, array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));
这篇关于Swift_TransportExceptionConnection无法与主机smtp.gmail.com建立的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!