好问题
Good  Question
  • 首 页
  • 问题
    • PHP
    • JAVA
    • CPlusPlus
    • C#
    • SQL
  • 关 于
  • 联 系
PHPMailer :SMTP Error: Could not connect to SMTP host. 关闭 返回上一级  

PHPMailer :SMTP Error: Could not connect to SMTP host.
+ 查看更多

发布日期:2018-03-10 14:54
分类:PHP
浏览次数:208
如下:
我在一些项目中使用了PHPMailer但是现在我有点不知所措。错误是这样显示的:
SMTP Error: Could not connect to SMTP host.
(SMTP错误,不能链接大SMTP主机)我用Thunderbird软件发送邮件是生效的,但是不能使用PHPMailer。这是ThunderBird的设置:
Server name: mail.exampleserver.com
Port: 587
Username: user@exampleserver.com
Secure Authentication: No
Connection Security: STARTTLS
我将它们与我使用PHPMailer的项目做了比较,是这样的:
Server name: mail.exampleserver2.com
Port: 465
Username: user@exampleserver2.com
Secure Authentication: No
Connection Security: SSL/TLS
我的PHP代码是这样的:
 $mail = new PHPMailer();
 $mail->IsSMTP(); // send via SMTP
 $mail->Host = SMTP_HOST; // SMTP servers
 $mail->Port = SMTP_PORT; // SMTP servers
 $mail->SMTPAuth = true; // turn on SMTP authentication
 $mail->Username = SMTP_USER; // SMTP username
 $mail->Password = SMTP_PASSWORD; // SMTP password
 $mail->From = MAIL_SYSTEM;
 $mail->FromName = MAIL_SYSTEM_NAME;
 $mail->AddAddress($aSecuredGetRequest['email']);
 $mail->IsHTML(true); // send as HTML
哪里有错误?

回答:

我认为因为在PHP中缺乏SSL的支持所以才出错的。
所以我启用extension=php_openssl.dll ,设置$mail->SMTPDebug = 1;
并且对这个方案进行提示。
更新于2017
$mail->SMTPDebug = 2;参考链接:
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#enabling-debug-output
上一篇如何在PHP中防止SQL注入?
如何处理PHPMailer中的报错信息?下一篇
下一篇如何处理PHPMailer中的报错信息?

最新文章

  • 函数`__construct`用来干嘛的
    发布日期:2018-03-26
  • 通过访客的IP得到他们的地区
    发布日期:2018-03-26
  • 合并两个PHP对象的最好的方法是什么?
    发布日期:2018-03-26
  • 该如何把一该如何把一个对象转化成数组?
    发布日期:2018-03-26
  • 什么是输出缓冲区?
    发布日期:2018-03-26
  • 在PHP中怎么把用逗号分隔的字符串分隔在一个数组里?
    发布日期:2018-03-26
  • 在PHP中使用foreach循环时查找数组的最后一个元素
    发布日期:2018-03-26
关于好问
收集整理一些有用的问题和回答,造福中国的程序旺和IT喵们!
友情链接
起飞页 
相关信息
版权声明
Copyright © 2016 - 2022  苏州卡达网络科技有限公司 备案号:苏ICP备09008221号