在我使用新的IP地址创建新的服务器应用程序(新应用程序是旧的应用程序)后,我再也无法从相同的代码和相同的身份验证发送邮件。
我得到了:
服务器 - >客户:220 smtp.gmail.com ESMTP o2sm6648795wjo.3 - gsmtp 客户 - >服务器:EHLO www.site.co SERVER - >客户: 250-smtp.gmail.com为您服务,[178.62.1.7] 250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8客户端 - >服务器:STARTTLS服务器 - >客户:220 2.0.0准备就绪 启动TLS CLIENT - >服务器:EHLO www.site.co SERVER - > 客户:250-smtp.gmail.com为您服务,[178.62.1.7] 250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8客户端 - >服务器:AUTH登录服务器 - >客户:334 VXNlcm5hbWU6客户端 - >服务器: cHJlZGljdG9sb2d5c3lzdGVtQGdtYWlsLmNvbQ == SERVER - >客户:334 UGFzc3dvcmQ6客户端 - >服务器:Nm5iNURydjs = SERVER - >客户: 534-5.7.14 请通过网络浏览器登录 和534-5.7.14然后再试一次.534-5.7.14了解更多at534 5.7.14 https://support.google.com/mail/answer/78754 o2sm6648795wjo.3 - gsmtp SMTP错误:密码命令失败:534-5.7.14 请通过网络浏览器登录 和534-5.7.14然后再试一次.534-5.7.14了解更多at534 5.7.14 https://support.google.com/mail/answer/78754 o2sm6648795wjo.3 - gsmtp SMTP错误:无法进行身份验证。客户 - >服务器:退出服务器 - > 客户端:221 2.0.0关闭连接o2sm6648795wjo.3 - gsmtp SMTP 连接失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting消息 无法发送.Mailer错误:SMTP连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
,代码是:
include_once('phpmailer/PHPMailerAutoload.php');
echo $_SERVER['DOCUMENT_ROOT'];
function sendmail($body){
//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';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6
//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;
$mail->Username = 'mail@gmail.com'; // SMTP username
$mail->Password = 'pass'; // SMTP password
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->From = 'from@from.net';
$mail->FromName = 'Site';
$mail->AddAddress('to@yahoo.com', 'To'); // Add a recipient
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Site: New unmapped teams found!';
$mail->Body = $body;
$mail->AltBody = $body;
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
}