PHPMailer与GMail:SMTP错误 [英] PHPMailer with GMail: SMTP Error

查看:84
本文介绍了PHPMailer与GMail: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.

如何解决此问题?

感谢所有帮助

推荐答案

首先要注意的是: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

这篇关于PHPMailer与GMail:SMTP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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