如何解决密码命令失败错误在php中发送邮件

时间:2022-04-04 18:12:30

can someone help me to find what is wrong with the following code because when i try to send mail in php i am getting the following error

有人可以帮我找到以下代码有什么问题,因为当我尝试在php中发送邮件时,我收到以下错误

2015-01-05 09:18:20 CLIENT -> SERVER: EHLO localhost 
2015-01-05 09:18:20 CLIENT -> SERVER: AUTH LOGIN 
2015-01-05 09:18:20 CLIENT -> SERVER: cGV0ZXJwcm9ncmFtZXIxOTkxQGdtYWlsLmNvbQ==  
2015-01-05 09:18:20 CLIENT -> SERVER: bWFuaTE5OTE= 
2015-01-05 09:18:21 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 xq4sm53656187pbb.21 - gsmtp 
2015-01-05 09:18:21 CLIENT -> SERVER: QUIT 
2015-01-05 09:18:21 SMTP connect() failed. Mailer Error: SMTP connect() failed.

code..

<?php
require "PHPMailerAutoload.php";
$mail = new PHPMailer(); 
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->Mailer="smtp";
$mail->CharSet="UTF-8";
$mail->SMTPSecure = 'tls';
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->Username = 'peter1991@gmail.com';
$mail->Password = 'password';
$mail->SMTPAuth = true;
$mail->From = 'peter1991@gmail.com';
$mail->FromName = 'peter';
$mail->AddAddress('manikandan@gmail.com');
$mail->AddReplyTo('john1991@gmail.com', 'John');
$mail->IsHTML(true);
$mail->Subject    = "PHPMailer Test Subject via Sendmail, basic";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";
$mail->Body    = "Hello";
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
?>

if my guess is right there must be some credential problem with gmail but i am totally confused i am in the middle of my college proj i cannot move further without solving this. any help is welcome thanks in advance

如果我的猜测是正确的,必须有一些gmail的凭证问题但我完全糊涂我在我的大学项目中间我不能没有解决这个问题进一步。任何帮助都欢迎提前感谢

2 个解决方案

#1


0  

$mail->SMTPSecure = 'ssl'; $mail->Host = 'smtp.gmail.com'; have a try

$ mail-> SMTPSecure ='ssl'; $ mail-> Host ='smtp.gmail.com';试试

#2


0  

Try this :

试试这个 :

$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->Username = "test@gmail.com";
$mail->Password = "test";

#1


0  

$mail->SMTPSecure = 'ssl'; $mail->Host = 'smtp.gmail.com'; have a try

$ mail-> SMTPSecure ='ssl'; $ mail-> Host ='smtp.gmail.com';试试

#2


0  

Try this :

试试这个 :

$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->Username = "test@gmail.com";
$mail->Password = "test";