无法使用 PHPMailer 通过 Google SMTP 发送邮件 [英] Unable to send mail through Google SMTP with PHPMailer
问题描述
我正在尝试结合使用 Google 的 SMTP 和 PHPMailer 发送邮件,但我无法让它工作.这是我的代码:
I'm trying to send out mail using Google's SMTP in combination with PHPMailer, but I can't get it to work. This is my code:
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "myemail@gmail.com";
$mail->Password = "**********";
$mail->Port = "465";
首先我不完全理解应该填写什么作为SMTPSecure",有人说ssl
",其他人说tls
".接下来对于端口",我可以输入465"或587".但是这些组合都不起作用...请注意,我使用的是常规 Gmail 帐户,而不是 Google Apps.在我的 Gmail 帐户中,我启用了POP 访问".
First I do not fully understand what should be filled in as 'SMTPSecure', some say 'ssl
', other say 'tls
'. Next for 'Port' I could enter '465' or '587'. But none of the combinations work... Note that I'm using a regular Gmail account and not Google Apps. In my Gmail account I've enabled 'POP access'.
我得到的错误是:必须先发出 STARTTLS 命令
".这意味着 SSL 失败,但不知道为什么......
The error I get is: "Must issue a STARTTLS command first
". Which means SSL failed, but don't know why...
推荐答案
好的,问题出在 PHPMailer 的版本上.我更新到 PHPMailer 版本 5,一切都很好.我使用的是 phpMailer 1.02 版.
Ok, the problem was the version of PHPMailer. I updated to PHPMailer version 5 and everything worked great. I was using phpMailer version 1.02.
这篇关于无法使用 PHPMailer 通过 Google SMTP 发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!