Sendmail PHP邮件程序错误:密码不被接受,无法进行身份验证

Sendmail PHP邮件程序错误:密码不被接受,无法进行身份验证,sendmail,phpmailer,contact-form,Sendmail,Phpmailer,Contact Form,我建立了一个联系表单,我想使用phpmailer发送电子邮件。我想用gmail作为主机。我输入了正确的用户名和密码,但不断收到错误消息。我还访问了gmail帐户中不太安全的内容。我不知道怎么了 <?php date_default_timezone_set('Etc/UTC'); require 'PHPMailerAutoload.php'; //Create a new PHPMailer instance $mail = new PHPMailer; //Tell PHPMa

我建立了一个联系表单,我想使用phpmailer发送电子邮件。我想用gmail作为主机。我输入了正确的用户名和密码,但不断收到错误消息。我还访问了gmail帐户中不太安全的内容。我不知道怎么了

<?php

date_default_timezone_set('Etc/UTC');

require 'PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;

//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;

//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';

//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;

//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';

//Whether to use SMTP authentication
$mail->SMTPAuth = true;

//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "truelabeltestingemail@gmail.com";

//Password to use for SMTP authentication
$mail->Password = "*********";

//Set who the message is to be sent from
$mail->setFrom('truelabeltestingemail@gmail.com', 'First Last');

//Set an alternative reply-to address
$mail->addReplyTo('noreplyt@truelabel.com', 'True Label');

//Set who the message is to be sent to
$mail->addAddress('truelabeltestingemail@gmail.com', 'Contact Form');

//Set the subject line
$mail->Subject = 'True Label Contact Form';

//Replace the plain text body with one created manually
$mail->Body = 'Message!!';



//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
} 

?>

把这本书读一遍。你在那里试过什么吗?它现在起作用了!就在我写了这个问题之后,我刚刚删除了主要的php并重新上传,它开始工作了!两天来我一直在努力使这项工作成功:)谢谢你,tho!!
SMTP -> FROM SERVER:220 mx.google.com ESMTP z195sm7240232iod.33 - gsmtp 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [67.211.175.4] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [67.211.175.4] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 
SMTP -> ERROR: Password not accepted from server: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 z195sm7240232iod.33 - gsmtp 
SMTP -> FROM SERVER:250 2.1.5 Flushed z195sm7240232iod.33 - gsmtp 
SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.