我正在使用 PHPMailer 通过 GMail 发送邮件。我使用的代码直接来自教程,它可以在我的笔记本电脑上完美运行。但是,在 Windows 2003 Server 上对此进行测试 - 它似乎总是返回一个 SMPT 错误:
SMTP 错误:无法连接到 SMTP 主机。邮件程序错误:SMTP 错误:无法连接到 SMTP 主机。
这是我在 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 上的另一台服务器并且它正在发送邮件。如果不是,请解释。
我该如何解决这个问题?
谢谢大家的帮助