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.
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)
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With