Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"SMTP Error: Could not authenticate" in PHPMailer

Tags:

php

phpmailer

I'm using PHPMailer in a Simple Script For Send Email's Through Gmail, and I'm getting an "Unknown Error" (At least for me!):

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've read about Configure OpenSSL For SSL/TLS Connections, and I did it. Apache And PHP Are properly-Configured (With OpenSSL extension Running in PHP and mod_ssl running in Apache 2.2.16).

This is The 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 = "[email protected]";   $Correo->Password = "gmailpassword";   $Correo->SetFrom('[email protected]','De Yo');   $Correo->FromName = "From";   $Correo->AddAddress("[email protected]");   $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!";   } ?> 

The Username and Password are OK, And I tried in Thunderbird, without any problem. I've also Used SSL Authentication and Port 465, getting the same Error.

like image 384
Alejandro Echeverri Avatar asked Oct 16 '10 16:10

Alejandro Echeverri


People also ask

How do I fix mailer error SMTP error could not authenticate?

Solution - Here's How To Resolve ItThe user must make sure that the client configurations contain the following valid SMTP configurations: SMTP server address. TLS Port number (if applicable) SSL Port number (if applicable)

Does PHPMailer use SMTP?

PHPMailer can use a non-local mail server (SMTP) if you have authentication. Further advantages include: It can print various kinds of error messages in more than 40 languages when it fails to send an email. It has integrated SMTP protocol support and authentication over SSL and TLS.

Could not be sent mailer error SMTP error could not authenticate?

You might have entered the wrong email credentials. In most cases, the Email address and Username should be the same. Use the same password that you use while logging into your email inbox.

What is SMTP authentication error?

If your mail server (also known as the SMTP server) rejects the user name and password, an Authentication Failed error will result. You will not be able to send any email until this problem is resolved, although it may not affect the ability to receive email.


1 Answers

I encountered this problem. To get it working, I had to go to myaccount.google.com -> "Sign-in & security" -> "Apps with account access", and turn "Allow less secure apps" to "ON" (near the bottom of the page).

Alternatively you can follow this direct link to these settings

enter image description here

like image 113
cwd Avatar answered Oct 08 '22 05:10

cwd