PHPmailer + Gmail

时间:2018-06-29 20:32:28

标签: php gmail phpmailer

我正在使用最新版本的PHPMailer通过我的Gmail帐户触发电子邮件,该应用程序在我的代码下方本地运行(从GitHub自己的PHPMailer复制,谈论从Gmail发送):

$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "xx@gmail.com";
$mail->Password = "xx";
$mail->setFrom('xx@gmail.com', 'First Last');
$mail->addAddress('xx@xx.com.br', 'John Doe');
$mail->Subject = 'PHPMailer GMail SMTP test';
$mail->Body = 'This is a plain-text message body';
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

错误消息:

2018-06-29 20:15:09 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP d18-v6sm6204628qtl.32 - gsmtp
2018-06-29 20:15:09 CLIENT -> SERVER: EHLO localhost
2018-06-29 20:15:09 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [189.120.238.241]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250 SMTPUTF8
2018-06-29 20:15:09 CLIENT -> SERVER: STARTTLS
2018-06-29 20:15:09 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
SMTP Error: Could not connect to SMTP host.
2018-06-29 20:15:10 CLIENT -> SERVER: QUIT
2018-06-29 20:15:10 SERVER -> CLIENT: 
2018-06-29 20:15:10 SMTP ERROR: QUIT command failed: 
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我还能尝试什么?

PS:Gmail中已将允许安全性较低的应用标记为“开”

0 个答案:

没有答案
相关问题