php smtp authentication issue

This is mail1.php page, when I started to use I receive authentication error.

  <?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";
 }
?>

I received below error message. I changed port numbers and try again, but no result. Can anyone help me ?

 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

Answers


Please try:

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

to enable SSL.


Need Your Help

Inputting data from url GET into a form and submitting on page load with javascript which then loads an ajax map causes the script to loop

javascript html ajax loops get

I've got a store locator currently on my website - this works by loading an ajax map when the user enters a postcode, this all works fine on the one page that it is on.