问题描述
我正在使用 PHPMailer 通过 GMail 发送邮件.我使用的代码直接来自教程,它可以在我的笔记本电脑上完美运行.但是,在 Windows 2003 Server 上对此进行测试 - 它似乎总是返回一个 SMPT 错误:
I am making use of PHPMailer to send mail through GMail. The code I use is straight from a tutorial and it works perfectly on my laptop. However, testing this on a Windows 2003 Server - it seems to always return an SMPT error:
SMTP 错误:无法连接到 SMTP主持人.邮件程序错误:SMTP 错误:可能未连接到 SMTP 主机.
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
这是我在 PHPMailer 中使用的设置:
Here is the settings I use in PHPMailer:
include("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // use ssl
$mail->Host = "smtp.gmail.com"; // GMAIL's SMTP server
$mail->Port = 465; // SMTP port used by GMAIL server
我可以自信地说这不是端口问题,因为我正在连接到端口 465 上的另一台服务器并且它正在发送邮件.如果不是,请解释.
Can I say with confidence that this isn't a port issue, since I am connecting to another server on port 465 and it is sending mail. If not, please explain.
我该如何解决这个问题?
How can I resolve this issue?
感谢大家的帮助
推荐答案
第一件事要注意:Gmail 使用 TLS.不知道用 SSL 代替 TLS 是否会有很大的不同,但 SSL 是 TLS 的前身.
First thing notice off-hand: Gmail uses TLS. Don't know if having SSL instead of TLS will make much of a difference but SSL is the predecessor to TLS.
我还建议检查一下,它的 phpmailer 是为使用 gmail 而定制的.PHPGMailer
I recommend checking out also, its phpmailer customized for using gmail. PHPGMailer
这篇关于带有 GMail 的 PHPMailer:SMTP 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)