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
• 7,860 points
27 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,680 points
2,259 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,680 points
1,016 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,680 points
6,370 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,680 points
1,053 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
• 15,250 points
18 views
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
504 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
8,978 views
0 votes
1 answer

Failure uploading Image on AmazonS3 with PHP SDK

Try this, I took it out from ...READ MORE

answered May 4, 2018 in AWS by Cloud gunner
• 4,650 points
2,011 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP