phpmailer SMTP错误:密码命令失败



我正在尝试从网站发送反馈到邮件ID,但我遇到了此错误:

2017-12-03 12:03:48无法访问文件:/var/tmp/file.tar.gz 2017-12-03 12:03:48无法访问文件:/TMP/Image.jpg 2017 2017-12-03 12:03:48服务器 ->客户端:220 smtp.gmail.com esmtp p42sm12855091wrb.28-GSMTP 2017-12-03 12:03:48客户-03 12:03:48服务器 ->客户端:250-smtp.gmail.com在您的服务中,[185.27.134.45] 250 size 35882577 250-8bitmime 250-starttls 250-enhanced-enhanced-enhanceStatuscodes 250 pipipelining 250-50-Pipielining 250-Chunkunking 250-chunkunking 250-Smtputf 8 2017-12-03 12:03:48客户端 ->服务器:Starttls 2017-12-03 12:03:48服务器 ->客户端:220 2.0.0准备启动TLS 2017-12-03 12:03:48客户端 ->服务器:EHLO www.shreephotovision.ml 2017-12-03 12:03:48服务器 ->客户端:250-SMTP.GMAIL.com在您的服务中,[185.27.134.45] 250-Size 250-Size 358882577 250-8Bit 250-8bit 250-auth 250-auth-auth登录普通XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH XOAUTH 250-ENHANCEDSTATUSCODES 250 PIPIPELININID 250-CHUNKING 250 SMTPUTF8 2017-12-03 12:03:03:03:48 ->服务器 ->服务器 ->服务器:服务器:BW5IQDI4MDC = 2017-12-03 12:03:49服务器 ->客户端:534-5.7.14请通过您的Web浏览器登录和534-5.7.14,然后重试。534-5.7.14了解更多信息,请访问534 5.7.14 https://support.google.com/mail/mail/answer/78754 P42SM12855091WRB.28-GSMTP 2017-12-12-03 2017-12-03 12:03:49 SMTP错误:-5.7.14请通过您的Web浏览器和534-5.7.14登录,然后重试。534-5.7.14了解更多信息,请访问534 5.7.14 https://support.google.com/mail/answer/78754 P42SM12855091WRB.28-GSMTP 2017-12-03 12:03:49 SMTP ERROR2017-12-03 12:03:49客户端 ->服务器:退出2017-12-03 12:03:49服务器 ->客户端:221 2.0.0关闭连接P42SM12855091WRB.28- GSMTP 2017-12-03 12:03 12:03 12:03 12:03:49 smtp connect()失败。无法发送https://github.com/phpmailer/phpmailer/wiki/troubleshooting消息。https://github.com/phpmailer/phpmailer/wiki/troubleshooting

这是我的代码:

<?php
$name = $_REQUEST['name'] ;
$mobile = $_REQUEST['mobile'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 2;                               // Enable verbose debug output
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';                 // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'milindbhuvad1988@gmail.com';                 // SMTP username
$mail->Password = '********';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to
$mail->setFrom('milindbhuvad1988@gmail.com', '');
$mail->addAddress('milindbhuvad1988@gmail.com', '');     // Add a recipient
$mail->addAddress('milindbhuvad1988@gmail.com');               // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML
$mail->Subject = 'You have received feedback from your website!';
$mail->Body    = "
<strong>Name:</strong> $name <hr>
<strong>Name:</strong> $mobile <hr>
<strong>Email:</strong> $email <hr>
<strong>Message:</strong> $message <hr>";
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {    
echo 'Message could not be sent.';    
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {   
?>
<script type="text/javascript">         
alert('Thanks Your Feedback');          
window.location.href='index.html';  
</script>';
<?php
}
?>

删除$mail->addAttachment('/var/tmp/file.tar.gz'); $mail->addAttachment('/tmp/image.jpg', 'new.jpg');或链接到要发送的实际附件。还更新php.ini中的证书对我有用。

最新更新