Home > Backend Development > Golang > Why Am I Getting SMTP Error 535: Username and Password Not Accepted?

Why Am I Getting SMTP Error 535: Username and Password Not Accepted?

Mary-Kate Olsen
Release: 2024-12-06 14:17:12
Original
236 people have browsed it

Why Am I Getting SMTP Error 535: Username and Password Not Accepted?

Understanding SMTP Email Sending Error 535: Username and Password Not Accepted

When attempting to test an outgoing email function, you may encounter an SMTP error 535, indicating "Username and Password not accepted." This issue arises when the provided credentials used to authenticate with the SMTP server are incorrect or not authorized to send emails on behalf of the specified email address.

Causes of SMTP Error 535

One potential cause of this error is using incorrect or disabled credentials. Ensure that the username (email address) and password used in the smtp.PlainAuth function are valid and active.

Another cause could be that the email account requires two-factor authentication (2FA). In this case, simply using a password may not be sufficient.

Solution: Enabling 2FA and Using an App Password

To resolve this error, here are some steps you can follow:

  1. Enable 2FA for your Google Account: Visit myaccount.google.com/security and enable 2FA if it's not already active.
  2. Generate an App Password: Navigate to security.google.com/settings/security/apppasswords and create an App Password specifically for the email sending function.
  3. Update the Sending Function: In the smtp.PlainAuth function, replace the password string with the generated App Password. This should grant the email sending function restricted access to send emails on behalf of your Google Account.

After implementing these changes, test the email sending function again. If the issue persists, verify that the App Password was correctly generated and entered.

The above is the detailed content of Why Am I Getting SMTP Error 535: Username and Password Not Accepted?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template