简体   繁体   English

邮件错误:SMTP connect()失败,通过smtp gmail的phpmailer

[英]Mailer Error: SMTP connect() failed, phpmailer via smtp gmail

 <?php
 require_once ("PHPMailer-master/PHPMailerAutoload.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
//$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "abc@gmail.com";
$mail->Password = "abcpassword";
$mail->SetFrom("abc@gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("sameone@domain.com");
 if(!$mail->Send())
    {

        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else
    {
    echo "Message has been sent";
    }
?>

I got the message: 我收到消息:

2015-07-11 08:06:17 CLIENT -> SERVER: EHLO action.ticambodia.org
2015-07-11 08:06:17 CLIENT -> SERVER: AUTH LOGIN
2015-07-11 08:06:17 CLIENT -> SERVER: c29lbmdrYW5lbEBnbWFpbC5jb20=
2015-07-11 08:06:17 CLIENT -> SERVER: a2FuZWxAbjB3 2015-07-11 08:06:17 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 mg19sm5958238oeb.10 - gsmtp
2015-07-11 08:06:17 SMTP Error: Could not authenticate.
2015-07-11 08:06:17 CLIENT -> SERVER: QUIT
2015-07-11 08:06:17 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

anyone,could help to find out what is the problem and how to solve it? 任何人都可以帮助找出问题所在以及如何解决?

The error is from the Google side. 错误是来自Google方面的。 For security reasons, Google Blocks less secure apps from accessing your Mails. 出于安全原因,Google阻止安全性较差的应用访问您的邮件。 But you can turn off this. 但是您可以关闭此功能。

  1. Sign in with "abc@gmail.com" from your browser. 在浏览器中使用“ abc@gmail.com”登录。
  2. Go to Allow less secure apps 转到允许安全性较低的应用
  3. Click 'Turn On' Radio button. 点击“打开”单选按钮。

Now check. 现在检查。 You can able to send E-mails 您可以发送电子邮件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM