带有 GMail 的 PHPMailer:SMTP 错误 [英] PHPMailer with GMail: SMTP Error

查看:66
本文介绍了带有 GMail 的 PHPMailer:SMTP 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆