php smtp身份验证问题

时间:2014-02-02 19:17:40

标签: php smtp

这是mail1.php页面,当我开始使用时,我收到身份验证错误。

  <?php 

 include 'class.phpmailer.php';
 $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->Host = "smtp.gmail.com";
 $mail->Port = 465; // 587
 $mail->IsHTML(true);
 $mail->Username = "behzatdeniz82@gmail.com";
 $mail->Password = "**********"; //Don't reveal password with others
 $mail->SetFrom("behzatdeniz82@gmail.com");
 $mail->Subject = "Test";
 $mail->Body = "hello";
 $mail->AddAddress("behzatdeniz99@gmail.com");
 if(!$mail->Send())
 {
 echo "Mailer Error: " . $mail->ErrorInfo;
 }
 else
 {
 echo "Message has been sent";
 }
?>

我收到以下错误消息。我更改了端口号并重试,但没有结果。谁能帮我 ?

 SMTP -> ERROR: AUTH not accepted from server: 530 5.7.0 Must issue a STARTTLS command 
 first. 8sm65292722eeq.15 - gsmtp SMTP Error: Could not authenticate. Mailer Error: 
 SMTP Error: Could not authenticate

1 个答案:

答案 0 :(得分:1)

请尝试:

$mail->Host = "ssl://smtp.gmail.com";

启用SSL。