Home > Backend Development > PHP Tutorial > Unable to Send Emails via Gmail: Troubleshooting \'535 Username and Password Not Accepted\' Error?

Unable to Send Emails via Gmail: Troubleshooting \'535 Username and Password Not Accepted\' Error?

Susan Sarandon
Release: 2024-10-18 18:03:29
Original
911 people have browsed it

Unable to Send Emails via Gmail: Troubleshooting

Unexpected SMTP Response Code: Troubleshooting "535 Username and Password Not Accepted" Error

When attempting to send emails via Gmail using SwiftMail, an error may occur indicating "Expected response code 250 but got code '535', with message '535-5.7.8 Username and Password not accepted.'" This issue can arise due to perceived spam behavior.

To resolve this problem, consider the following steps:

  • Disable Less Secure App Access: Enable "Allow less secure apps" in your Gmail settings to permit SwiftMail to bypass security restrictions.
  • Remove Captcha Verification: Disable Google's captcha verification to streamline the login process.
  • Enable Two-Step Verification: Enable two-step verification to enhance account security.

However, if these measures fail, implement the following solution:

  1. Enable Two-Step Verification: Visit Google's "Two-Step Verification" page and activate the feature.
  2. Create App Password: Generate an app password specifically for your email system.
  3. Update Environment File: Replace the Gmail password in your environment file (.env) with the app password generated in step 2.
  4. Restart Server: Restart your web server to apply the changes.

By completing these steps, you should be able to successfully send emails via Gmail using SwiftMail.

The above is the detailed content of Unable to Send Emails via Gmail: Troubleshooting '535 Username and Password Not Accepted' Error?. For more information, please follow other related articles on the PHP Chinese website!

source:php
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