duanlu6268 2015-07-26 13:00
浏览 84

smtp gmail服务器php邮件程序无法正常工作

I know this question has been asked many a times before. But the solutions didn't seem to help me . So hereby I am posting my code:

<?php
require("class.phpmailer.php");
require("class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP(); 
$mail->Host="smtp.gmail.com";
$mail->SMTPDebug=1; 
$mail->SMTPAuth=true;
$mail->SMTPSecure="ssl";
$mail->Port=465;  
$mail->Username ="me@gmail.com";
$mail->Password="mypassword";
$mail->AddAddress("to@yahoo.co.in");
$mail->SetFrom("me@gmail.com", "myname");
$mail->AddReplyTo("someone@gmail.com","someone");
$mail->Subject="Greetings from ME";
$mail->Body="Greeting !! I am glad you received this message";
$mail->WordWrap=50;
if($mail->send())
{
echo "Mail sent successfully";
}
else
{
echo "Sorry mail could not be sent because of error ".$mail->ErrorInfo;
}
?>

The SMTP Debug is:

CLIENT -> SERVER: EHLO messengerclick.byethost3.com 2015-07-26 12:49:42 CLIENT -> SERVER: AUTH LOGIN 2015-07-26 12:49:42    
CLIENT -> SERVER: Y2hlcm9ja3oxOUBnbWFpbC5jb20= 2015-07-26 12:49:42  
CLIENT -> SERVER: Y2hldGFucm9ja3MxOQ== 2015-07-26 12:49:43  
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 sc16sm22415466wjb.28 - gsmtp 2015-07-26 12:49:43 
SMTP Error: Could not authenticate. 2015-07-26 12:49:43 
CLIENT -> SERVER: QUIT 2015-07-26 12:49:43  SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Sorry mail could not be sent because of error SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

I have enabled access for unknown apps on my gmail account. I have also clicked on continue on this link http://www.google.com/accounts/DisplayUnlockCaptcha after signing in. I am running this from my byethost account. It is working fine for smtp.mail.yahoo.com

Please help me know what I am doing wrong.

  • 写回答

2条回答 默认 最新

  • dongnianwo8289 2015-07-26 13:09
    关注

    If you’re sure your password is correct, you can try these troubleshooting tips:

    • If you've turned on 2-Step Verification for your account, you might need to enter an App password.
    • Sign in to your account from the web version of Gmail at https://mail.google.com. Afterwards try accessing your messages in your mail app again.
    • If you're still having problems, visit http://www.google.com/accounts/DisplayUnlockCaptcha and sign in with your Gmail username and password. If necessary, enter the letters in the distorted picture.
    • Your mail app might not support the latest security standards. Learn how to allow less secure apps access to your account.
    • Make sure your mail app isn't set to check for new email too frequently. If your mail app checks for new messages more than once every 10 minutes, the app’s access to your account could be blocked.
    • Try changing your password according to our tips on creating a strong password.

    Source.

    Here, you can allow less secure apps. Click on Turn On to allow less secure apps having your username and password.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算