我正在使用PHPMailer通过GMail发送邮件。 我使用的代码直接来自教程,它在我的笔记本电脑上完美地工作。 但是,在Windows 2003服务器上测试此代码时,似乎总是返回SMPT错误:
SMTP错误:无法连接到SMTP主机。 邮件程序错误:SMTP错误:无法连接到SMTP主机。
以下是我在PHPMailer中使用的设置:
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端口发送邮件的服务器。如果不是这样,请解释一下。
我该如何解决这个问题?
感谢所有提供帮助的人。
$mail->Username = "myUsername"; // SMTP用户名
和$mail->Password = "myPassword"; // SMTP密码
才能成功发送邮件。 - D.Tate