Tôi đang sử dụng PHPMailer trong Tập lệnh đơn giản để gửi email qua Gmail và tôi nhận được "Lỗi không xác định" (Ít nhất là cho tôi!):"Lỗi SMTP: Không thể xác thực" trong PHPMailer
SMTP Error: Could not authenticate. Error: SMTP Error: Could not authenticate.
SMTP server error: 5.7.1 Username and Password not accepted. Learn more at 535 5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 p38sm2467302ybk.16
Tôi đã đọc về Định cấu hình OpenSSL Đối với kết nối SSL/TLS và tôi đã làm điều đó. Apache và PHP được cấu hình đúng (Với phần mở rộng OpenSSL Chạy trong PHP và mod_ssl đang chạy trong Apache 2.2.16).
này là The PHP Script:
<?php
require_once ("PHPMailer\class.phpmailer.php");
$Correo = new PHPMailer();
$Correo->IsSMTP();
$Correo->SMTPAuth = true;
$Correo->SMTPSecure = "tls";
$Correo->Host = "smtp.gmail.com";
$Correo->Port = 587;
$Correo->UserName = "[email protected]";
$Correo->Password = "gmailpassword";
$Correo->SetFrom('[email protected]','De Yo');
$Correo->FromName = "From";
$Correo->AddAddress("[email protected]");
$Correo->Subject = "Prueba con PHPMailer";
$Correo->Body = "<H3>Bienvenido! Esto Funciona!</H3>";
$Correo->IsHTML (true);
if (!$Correo->Send())
{
echo "Error: $Correo->ErrorInfo";
}
else
{
echo "Message Sent!";
}
?>
Các Username và Password là OK, Và tôi đã cố gắng trong Thunderbird, mà không cần bất kỳ vấn đề. Tôi cũng đã sử dụng Xác thực SSL và Cổng 465, nhận được cùng Lỗi.
Điều này là lạ, vì lỗi khá rõ ràng trỏ đến lỗi tên người dùng/mật khẩu thay vì vấn đề giao thức. Bạn không có ký tự đặc biệt nào trong mật khẩu có thể bị chuyển nhầm? –