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, 2022 in PHP by narikkadan
• 63,600 points
4,520 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,840 points
4,652 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,840 points
2,280 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,840 points
14,034 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,840 points
5,095 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, 2022 in PHP by Kichu
• 19,040 points
3,124 views
0 votes
0 answers

Mailer Error: SMTP connect() failed in php mailer( https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting)

Here is code for sending email from ...READ MORE

Jun 2, 2022 in PHP by Kichu
• 19,040 points
13,085 views
0 votes
0 answers

phpmailer error "Could not instantiate mail function"

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

Jun 13, 2022 in PHP by narikkadan
• 63,600 points
2,421 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, 2022 in PHP by narikkadan
• 63,600 points
1,943 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