我使用PHPMailer得到了这个错误:
SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.
以下是代码:
function send_email($reciever = "e.salamati.taba@gmail.com", $mail_arr = '') { // This function will be upgraded later
$mail = new PHPMailer();
$body = $mail_arr['body'];
//$body = eregi_replace("[\]", '', $body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = true;
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable 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; // set the SMTP port for the GMAIL server
$mail->Username = "user"; // GMAIL username
$mail->Password = "pass"; // GMAIL password
$mail->SetFrom('e.salamati.taba@gmail.com', 'no-reply gmail.com');
$mail->Subject = $mail_arr['subject'];
$mail->MsgHTML($body);
echo "-----------------------";
$address = $reciever;
$mail->AddAddress($address, "e.salamati.taba@gmail.com");
if(! $mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
}
我也看到this,但仍然遇到错误,是否有任何xampp配置或导致问题的原因? 提前谢谢......