PHPMailer不断返回错误

时间:2014-05-28 22:52:39

标签: php email mailer

这是我的php文件:

<?php

require 'PHPMailerAutoload.php';
$mail = new PHPMailer;

if(isset($_POST['send'])){
date_default_timezone_set('Etc/UTC');
$email = $_POST['email'];
$name = $_POST["name"];
$subject = $_POST["subject"];
$message = $_POST["message"];
$mail -> isSMTP();
$mail->PluginDir = "/path/to/phpmailer/dir";
$mail -> SMTPDebug = 1;
$mail -> Host = "smtp.gmail.com";
$mail -> SMTPSecure = "ssl";
$mail -> Port = 465;
$mail -> SMTPAuth = true;
$mail -> Username = "xxx"; //username example@gmail.com
$mail -> password = "xxx"; //password

$mail -> setFrom("autobandendiscount@gmail.com", "Anwar Elbouhdifi");
$mail -> addAddress($email, $name);



$mail -> Subject = $subject;
$mail -> Body = $message;
$mail -> AltBody = $message;

if(! $mail -> send()){
    echo"message error: " . $mail -> ErrorInfo;
}else{
    echo"Success!" ;
}

}

&GT;

邮件程序返回此错误

  

2014-05-28 22:51:05客户 - &gt;服务器:EHLO localhost 2014-05-28 22:51:05客户端 - &gt;服务器:AUTH LOGIN 2014-05-28 22:51:05客户端 - &gt;服务器:YXV0b2JhbmRlbmRpc2NvdW50QGdtYWlsLmNvbQ == 2014-05-28 22:51:05客户端 - &gt;服务器:2014-05-28 22:51:05 SMTP错误:密码命令失败:535-5.7.8不接受用户名和密码。了解更多信息,请访问535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 r5sm46692086wjq.26 - gsmtp 2014-05-28 22:51:05客户 - &gt; SERVER:QUIT SMTP connect()失败。消息错误:SMTP connect()失败。

我知道它说用户名和密码不被接受,但我知道100%是正确的密码和用户名。

1 个答案:

答案 0 :(得分:3)

可能不是解决方案但值得一试:用大P拼写密码。