尝试通过PHP邮件程序从本地xampp发送电子邮件但收到错误:
-
SMTP - >错误:服务器不接受密码:535-5.7.8不接受用户名和密码 .
-
SMTP - >错误:服务器不接受MAIL:530-5.5.1需要验证 .
-
以下发件人地址失败:azadlm460@gmail.com:MAIL未被服务器接受,530,5.5.1
代码是:
<?php
function sendOTP($clientemail,$num) {
require('phpmailer/class.phpmailer.php');
$message_body = "One Time Password for PHP login authentication is:
" . $num;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "Azad";
$mail->Password = "mypass";
$mail->SetFrom("myemail");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("anotheremail");
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "Message has been sent";
}
}
?>
已经尝试过:
在root中添加了PHP邮件程序 .
允许访问安全性较低的应用 .
更改了Gmail的密码 .
帐户访问已启用 .