尝试使用phpmailer但它不起作用:SMTP错误:无法进行身份验证

时间:2016-07-18 20:20:11

标签: phpmailer

$mail= new PHPmailer();
$mail-> IsSMTP();//telling the class to use SMTP
$mail->Host = gethostbyname('smtp.gmail.com');//SMTP server
$mail->SMTPDdebug =2; //enables SMTP debug information
$mail->SMTPAuth = true;//enable SMTP authentication
$mail->SMTPSecure = "tsl";//set the prefix to the server

$mail->Port =587;//set the SMTP port for thr GMAIL server
$mail->Username = "andriyvyhor@gmail.com";//GAMAIL username
$mail->Password ="andriyvyhor";
$mail->SetFrom=("andriyvyhor@gmail.com");
$mail->AddAddress("andriyvyhor@gmail.com");
$mail->Subject="TEXT";
$mail->Body="You sell your shares";
if(!$mail->Send())
{
    echo "Mailer erro:".$mail->ErrorInfo;
}
else
{
    echo "Message sent!";
}
}

我收到此错误

SMTP错误:无法进行身份验证。邮件程序错误:SMTP错误:无法进行身份验证。

0 个答案:

没有答案