Php mailer gmail smtp error could not authenticate

While connecting your email account through the SMTP method, you may encounter SMTP Error: Could not authenticate error.

1. 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.

2. You might have the wrong SMTP settings.

  • Confirm your SMTP server address, TLS Port number, or SSL Port number with your email service provider and use the correct SMTP settings.

3. Your email account has multi-factor authentication enabled:

SMTP connection can't be established If you have turned on the 2-factor authentication for your email account so you either need to turn it off or generate an app password for your email account. That app password can be used in your SalesHandy account to connect the email account via SMTP method. Many email providers allow users to generate an app-specific password and every email service provider has different methods of creating app passwords. Please follow the below articles to know the steps of generating app passwords [Application-Specific Passwords] as per your email provider. Please note that you need to use the generated password while connecting your email account with SalesHandy.

  • Click here to know how the app password is generated in Gmail.
  • Click here to know how the app password is generated in Yahoo mail.
  • Click here to know how the app password is generated in Zoho mail.
  • Click here to know how the app password is generated in Yandex mail.

4. The SMTP connection is disabled by your email service provider. 

Although it happens rarely, sometimes, the email providers keep the SMTP connection disabled so it can't be connected via the SMTP method. In that case, users are requested to reach out to their email service provider to get SMTP enabled. 

If you're not sure about why you got this error while connecting your email via SMTP, please contact our support team at [email protected] so we can share possible reasons behind the connection issue.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us

Last updated on July 27, 2022

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 //mail.google.com/support/bin/answer.py?answer=14257 p38sm2467302ybk.16

I configured the OpenSSL For SSL/TLS Connections. 

This is my PHP Script:

 

Can someone help me solve this issue?

Please check these things before submitting your issue:

  • Make sure you're using the latest version of PHPMailer
  • Check that your problem is not dealt with in the troubleshooting guide, especially if you're having problems connecting to Gmail or GoDaddy
  • Include sufficient code to reproduce your problem
  • If you're having an SMTP issue, include the debug output generated with SMTPDebug = 2 set
  • If you have a question about how to use PHPMailer [rather than reporting a bug in it], tag a question on Stack Overflow with phpmailer, but search first!

Problem description

When i trying send message from smtp.gmail.com, with ssl, or tls, or different ports, doesnt matter, it's throw exception to me.
I have Allowed less secure apps in gmail, and i visit captcha confirmation

Code to reproduce

$mail->isSMTP[];
$mail->SMTPDebug = 2;
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->CharSet = "UTF-8";

$mail->Username = "";
$mail->Password = "*******";
$mail->setFrom["", "Alex"];
$mail->Subject = "Тест, отправка письма";
$mail->msgHTML["Message"];
$mail->addAddress[""];

if [!$mail->send[]] {
    $mail->ErrorInfo;
} else {
    echo "123";
}

Debug output

2017-10-23 19:44:18 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP q24sm1694776lff.48 - gsmtp

2017-10-23 19:44:18 CLIENT -> SERVER: EHLO *my_server*

2017-10-23 19:44:18 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [*my_server*]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8

2017-10-23 19:44:18 CLIENT -> SERVER: AUTH LOGIN

2017-10-23 19:44:18 SERVER -> CLIENT: 334 VXNlcm5hbWU6

2017-10-23 19:44:18 CLIENT -> SERVER: YXJldm9sdXRpb25wcm9qZWN0QGdtYWlsLmNvbQ==

2017-10-23 19:44:18 SERVER -> CLIENT: 334 UGFzc3dvcmQ6

2017-10-23 19:44:18 CLIENT -> SERVER: cmV2b2x1dGlvbjEyMw==

2017-10-23 19:44:18 SERVER -> CLIENT: 534-5.7.14  Please log in via your web browser and534-5.7.14 then try again.534-5.7.14  Learn more at534 5.7.14  //support.google.com/mail/answer/78754 q24sm1694776lff.48 - gsmtp

2017-10-23 19:44:18 SMTP ERROR: Password command failed: 534-5.7.14  Please log in via your web browser and534-5.7.14 then try again.534-5.7.14  Learn more at534 5.7.14  //support.google.com/mail/answer/78754 q24sm1694776lff.48 - gsmtp

SMTP Error: Could not authenticate.

2017-10-23 19:44:18 CLIENT -> SERVER: QUIT

2017-10-23 19:44:19 SERVER -> CLIENT: 221 2.0.0 closing connection q24sm1694776lff.48 - gsmtp

SMTP Error: Could not authenticate.

How do I fix SMTP authentication error in Gmail?

To fix this problem you need:.
Make sure that you've entered the correct password..
Check if you have enabled the two-factor authentication. ... .
Enable less secure apps access in your Google account settings. ... .
Log out from all the other Google accounts. ... .
Make sure that your password doesn't contain # or ^ symbols..

Could not authenticate mailer error SMTP error could not authenticate?

Error: SMTP error: could not authenticate This error indicates that the client could not authenticate with the email server. It can be the cause of multiple reasons, for example: The user did not enter valid credentials when logging in. The user did not verify with the multi-factor authentication mechanisms enabled.

How do I fix SMTP authentication error?

SMTP connection can't be established If you have turned on the 2-factor authentication for your email account so you either need to turn it off or generate an app password for your email account. That app password can be used in your SalesHandy account to connect the email account via SMTP method.

How use Gmail SMTP in PHP?

Writing the PHP Code to Send Email using Gmail SMTP.
Step 1: Download PHPMailer library from this github link. ... .
Step 2: Writing the PHP Code to make an SMTP connection. ... .
Step 3: Include packages and files for PHPMailer and SMTP protocol: ... .
Step 4: Initialize PHP Mailer and set SMTP as mailing protocol:.

Bài mới nhất

Chủ Đề