Tôi đã chạy PHPMailer một năm nay trên máy chủ php. Tất cả mọi thứ vẫn ổn cho đến 3 ngày trước khi tôi bắt đầu nhận được các lỗi sau:PHPMailer - Không thể xác thực
SMTP Error: Could not authenticate.
phép ứng dụng kém an toàn là ON
Dưới đây là đoạn code:
function SendEmail($to,$cc,$bcc,$subject,$body) {
require 'PHPMailerAutoload.php';
$mail = new PHPMailer(true);
$mail->SMTPDebug = 1;
try {
$addresses = explode(',', $to);
foreach ($addresses as $address) {
$mail->AddAddress($address);
}
if($cc!=''){
$mail->addCustomHeader("CC: " . $cc);
}
if($bcc!=''){
$mail->addCustomHeader("BCC: " . $bcc);
}
$mail->IsSMTP();
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587;
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "myemailpass"; // SMTP password
$webmaster_email = "[email protected]"; //Reply to this email ID
$name=$email;
$mail->From = $webmaster_email;
$mail->FromName = "Service";
//$mail->AddReplyTo($webmaster_email, "DiFractal Customer Service");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = $subject;
$mail->Body = $body;
return $mail->Send();
} catch (phpmailerException $e) {
$myfile = fopen("debug_email.txt", "w");
fwrite($myfile,$e->errorMessage() . "\n" . $mail->ErrorInfo);
fclose($myfile);//Pretty error messages from PHPMailer
} catch (Exception $e) {
$myfile = fopen("debug_email_stp.txt", "w");
fwrite($myfile,$e->getMessage());
fclose($myfile);//Pretty error messages from PHPMailer
}
}
Lưu ý tôi chỉ cập nhật PHPMailer lên phiên bản mới nhất để thử khắc phục sự cố nhưng không có gì thay đổi! Phiên bản 5.2.2 cũ vẫn còn có cùng một vấn đề!
CHỈNH SỬA: Tôi vừa có một email thành công được chuyển tới google và được gửi đúng cách. Mà bây giờ làm cho tôi câu hỏi nếu nó là vấn đề lag hoặc một cái gì đó của loại đó. Có ai biết làm thế nào phpmailer chức năng dưới tải cao hoặc nếu tải cao có thể gây ra lỗi trên?
Một câu hỏi rất phổ biến. Bạn đã kiểm tra [** google **] chưa (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=phpmailer%20gmail%20could%20not%20authenticate)? –
@Michael_B Tất nhiên. Quá trình chuẩn cho tôi là nghiên cứu trang đầu tiên của kết quả tìm kiếm từ google trước khi đăng trên ngăn xếp. –
Quá trình chuẩn cho tôi, khi một câu hỏi rất phổ biến, là hỏi. Hầu hết không phải là siêng năng như bạn :-) –