"SMTP错误:无法验证"在PHPMailer中 [英] "SMTP Error: Could not authenticate" in PHPMailer

查看:71
本文介绍了"SMTP错误:无法验证"在PHPMailer中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用于通过Gmail发送电子邮件的简单脚本中使用PHPMailer,但遇到未知错误"(至少对我来说!):

I'm using PHPMailer in a Simple Script For Send Email's Through Gmail, and I'm getting an "Unknown Error" (At least for me!):

SMTP错误:无法验证. 错误:SMTP错误:无法 验证.

SMTP Error: Could not authenticate. Error: SMTP Error: Could not authenticate.

SMTP服务器错误:5.7.1用户名和 密码不被接受.了解更多 535 5.7.1 http://mail.google.com/support/bin/answer.py ?answer = 14257 p38sm2467302ybk.16

SMTP server error: 5.7.1 Username and Password not accepted. Learn more at 535 5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 p38sm2467302ybk.16

我已经阅读了有关为SSL/TLS连接配置OpenSSL的信息,并且做到了.正确配置了Apache和PHP(具有在PHP中运行的OpenSSL扩展名和在Apache 2.2.16中运行的mod_ssl).

I've read about Configure OpenSSL For SSL/TLS Connections, and I did it. Apache And PHP Are properly-Configured (With OpenSSL extension Running in PHP and mod_ssl running in Apache 2.2.16).

这是PHP脚本:

 <?php
  require_once ("PHPMailer\class.phpmailer.php");
  $Correo = new PHPMailer();
  $Correo->IsSMTP();
  $Correo->SMTPAuth = true;
  $Correo->SMTPSecure = "tls";
  $Correo->Host = "smtp.gmail.com";
  $Correo->Port = 587;
  $Correo->UserName = "foo@gmail.com";
  $Correo->Password = "gmailpassword";
  $Correo->SetFrom('foo@gmail.com','De Yo');
  $Correo->FromName = "From";
  $Correo->AddAddress("bar@hotmail.com");
  $Correo->Subject = "Prueba con PHPMailer";
  $Correo->Body = "<H3>Bienvenido! Esto Funciona!</H3>";
  $Correo->IsHTML (true);
  if (!$Correo->Send())
  {
    echo "Error: $Correo->ErrorInfo";
  }
  else
  {
    echo "Message Sent!";
  }
?>

用户名和密码都可以,我在Thunderbird中尝试了,没有任何问题. 我还使用了SSL身份验证和端口465,但得到了相同的错误.

The Username and Password are OK, And I tried in Thunderbird, without any problem. I've also Used SSL Authentication and Port 465, getting the same Error.

推荐答案

尝试以下方法:

$ Correo-> 用户名 ="foo@gmail.com";

$Correo->Username = "foo@gmail.com";

我对其进行了测试,并且在没有其他更改的情况下完美运行

I tested it and its working perfectly without no other change

这篇关于"SMTP错误:无法验证"在PHPMailer中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆