PHPMailer发送到GMAIL失败


PHPMailer failed send to GMAIL

抨击PHPMailer发送电子邮件,而不是如果我的服务器配置错误,或者我的设置是邮件或我的代码错误。这是我使用的代码

$nombre = $_POST['name'];
$email = $_POST['email'];
$mensaje = $_POST['mensaje'];
require 'vendor/PHPmailer/PHPMailerAutoload.php';
$mail = new PHPMailer(); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
$body .= "<b>Hola</b>";
try {
     //$mail->Host       = "mail.gmail.com"; // SMTP server
      $mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
      $mail->SMTPAuth   = true;                  // enable SMTP authentication
      $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
      $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
      $mail->Port       = 465;   // set the SMTP port for the GMAIL server
      $mail->SMTPKeepAlive = true;
      $mail->Mailer = "smtp";
      $mail->Username   = "test@mydomain.com";  // GMAIL username
      $mail->Password   = "12345678";            // GMAIL password
      $mail->AddAddress($email, 'abc');
      $mail->SetFrom('nhernandez@fullmecanic.com', 'def');
      $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
      $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
      $mail->MsgHTML($body);
      $mail->Send();
      echo "Message Sent OK</p>'n";
} catch (phpmailerException $e) {
      echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
      echo $e->getMessage(); //Boring error messages from anything else!
}

配置php.ini

[mail function]
SMTP = localhost
smtp_port = 25
extension=php_openssl.dll

还为我在论坛中发现的所有不安全的东西配置我的gmail帐户,但它不起作用,我得到了这个应用程序:

2016-05-03 19:58:37 CLIENT -> SERVER: EHLO mydomain.com 2016-05-03 19:58:37 CLIENT -> SERVER: AUTH LOGIN 2016-05-03 19:58:37    CLIENT -> SERVER: bmhlcm5hbmRlekBmdWxsbWVjYW5pYy5jbA== 2016-05-03 19:58:37  CLIENT -> SERVER: ODEzODI5My4u 2016-05-03 19:58:38  SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 j80sm38623ywg.48 - gsmtp 2016-05-03 19:58:38 SMTP Error: Could not authenticate. 2016-05-03 19:58:38 CLIENT -> SERVER: QUIT 2016-05-03 19:58:38  SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message Sent OK

如果你仔细看,我在发送电子邮件后,打印"Message Sent OK",这会出现,但也会出现身份验证错误

您是否使用Google API客户端阅读过Gmail XOAUTH2。它与你有关吗?

您是否尝试过ping smtp.gmail.com并确保从托管脚本的服务器得到响应?

也可以尝试端口587。

有点像是根据他们的故障排除指南在这里吐槽,因为我无法测试你的设置。