Home > Backend Development > Golang > Why Is My Go Code Receiving an SMTP Error 535: Username and Password Not Accepted by Gmail?

Why Is My Go Code Receiving an SMTP Error 535: Username and Password Not Accepted by Gmail?

Susan Sarandon
Release: 2024-12-09 21:51:11
Original
410 people have browsed it

Why Is My Go Code Receiving an SMTP Error 535: Username and Password Not Accepted by Gmail?

SMTP Error: 535 Username and Password Not Accepted by Gmail

When attempting to test outgoing emails from localhost using the provided function, users encounter the error "smtp error: 535 5.7.8 Username and Password not accepted for gmail in go." Despite correctly entering the credentials for the gmail account and enabling less secure app access, this error persists.

Potential Solutions

The issue likely arises due to the usage of a personal Gmail account instead of a G Suite account. To resolve this, follow these steps:

  1. Enable 2-Factor Authentication (2FA): Navigate to myaccount.google.com/security to enable 2FA if not already done.
  2. Generate an App Password: Visit https://security.google.com/settings/security/apppasswords and create an App Password instead of using the regular password. App Passwords provide restricted access to the account, allowing the app to send emails without compromising the full Google Account.
  3. Update the Code: Replace the hardcoded password in the function with the newly generated App Password.

By implementing these solutions, users can bypass the error and successfully send emails from localhost using the provided function for testing purposes.

The above is the detailed content of Why Is My Go Code Receiving an SMTP Error 535: Username and Password Not Accepted by Gmail?. 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