邮件程序错误:SMTP connect()失败,phpmailer通过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?

dongyuandou2521
dongyuandou2521 如果你表现出最轻微的尝试来解决问题,你会得到更多的同情,特别是当你面前有好的建议时。阅读您的错误消息。如果您按照提供的文档链接,它会告诉您确切需要做什么来解决您的问题。您还将代码基于一个旧示例-确保您使用的是最新的PHPMailer。
5 年多之前 回复
dsb238100
dsb238100 错误似乎很清楚
5 年多之前 回复

1个回答



错误来自Google方面。 出于安全原因,Google阻止安全性较低的应用访问您的邮件。 但你可以关掉这个。 </ p>


  1. 使用浏览器中的“abc@gmail.com”登录。</ li>
  2. 转到允许安全性较低的应用 </ li>
  3. 点击”开启“单选按钮。</ li>
    < / ol>

    现在检查。 您可以发送电子邮件</ p>
    </ div>

展开原文

原文

The error is from the Google side. For security reasons, Google Blocks less secure apps from accessing your Mails. But you can turn off this.

  1. Sign in with "abc@gmail.com" from your browser.
  2. Go to Allow less secure apps
  3. Click 'Turn On' Radio button.

Now check. You can able to send E-mails

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐