PHPMailer with GMail: SMTP Error(带有 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 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有 GMail 的 PHPMailer:SMTP 错误
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
