SMTP Error Could not authenticate in PHPMailer

0 votes

I want to send emails in Gmail using PHP Mailer in a Simple Script but I am getting an error:

SMTP Error: Could not authenticate. Error: SMTP Error: Could not authenticate.

SMTP server error: 5.7.1 Username and Password not accepted. Learn more at 535 5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 p38sm2467302ybk.16

I configured the OpenSSL For SSL/TLS Connections. 

This is my PHP Script:

 <?php

  require_once ("PHPMailer\class.phpmailer.php");

  $Correo = new PHPMailer();

  $Correo->IsSMTP();

  $Correo->SMTPAuth = true;

  $Correo->SMTPSecure = "tls";

  $Correo->Host = "smtp.gmail.com";

  $Correo->Port = 587;

  $Correo->UserName = "foo@gmail.com";

  $Correo->Password = "gmailpassword";

  $Correo->SetFrom('foo@gmail.com','De Yo');

  $Correo->FromName = "From";

  $Correo->AddAddress("bar@hotmail.com");

  $Correo->Subject = "Prueba con PHPMailer";

  $Correo->Body = "<H3>Bienvenido! Esto Funciona!</H3>";

  $Correo->IsHTML (true);

  if (!$Correo->Send())

  {

    echo "Error: $Correo->ErrorInfo";

  }

  else

  {

    echo "Message Sent!";

  }

?>

Can someone help me solve this issue?

May 7 in PHP by narikkadan
• 37,260 points
2,186 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

error: Class 'PHPUnit_Framework_TestCase' not found in …?

Hello,  You can use TestCase instead PHPUnit_Framework_TestCase // use the following namespace use ...READ MORE

answered Apr 20, 2020 in PHP by Niroj
• 82,800 points
2,877 views
0 votes
1 answer

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in .?

Hello @kartik, You may get this error because ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,800 points
1,241 views
0 votes
1 answer
0 votes
1 answer

Error:PDOException could not find driver

Hello @kartik, You need to have a module ...READ MORE

answered Sep 14, 2020 in PHP by Niroj
• 82,800 points
9,394 views
0 votes
1 answer

Php exec() not returning error message in output

Hello @kartik, You need to capture the stderr too. Redirecting stderr to stdout should do ...READ MORE

answered Nov 18, 2020 in PHP by Niroj
• 82,800 points
2,098 views
0 votes
0 answers

PHPMailer: SMTP Error: Could not connect to SMTP host

I am having trouble sending mail through ...READ MORE

May 8 in PHP by Kichu
• 19,040 points
1,301 views
0 votes
0 answers
0 votes
0 answers

phpmailer error "Could not instantiate mail function"

I'm getting the error "Mailer Error: Could ...READ MORE

Jun 13 in PHP by narikkadan
• 37,260 points
656 views
0 votes
0 answers

PHPMailer SMTP ERROR: Failed to connect to server

This Code: <?php include("class.phpmailer.php"); include("class.smtp.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // ...READ MORE

Jun 27 in PHP by narikkadan
• 37,260 points
537 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP