Home >Backend Development >PHP Tutorial >How to Resolve Mail Server Error Code 535: \'Username and Password not accepted\' with Gmail and SwiftMailer?
Mail Server Error: "Username and Password not accepted" with Code 535
When attempting to send emails via Gmail using SwiftMailer, users may encounter the error message:
"Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted."
This issue can arise when Google suspects spam activity and temporarily restricts access to certain applications or devices. To resolve this, follow these steps:
1. Enable Two-Step Verification
Enable 2-step verification for your Google account to enhance security.
2. Create an App Password
Create an app password specific to your application or server. This password is different from your regular Google account password and should be used to access your Google account from third-party applications.
3. Update Environment File
Replace the original Gmail password in your environment file (e.g., .env) with the newly generated app password.
4. Restart the Server
Restart your Apache server or other application server to apply the changes.
Additional Tips:
By following these steps, you can resolve the "Username and Password not accepted" error and resume sending emails through Gmail.
The above is the detailed content of How to Resolve Mail Server Error Code 535: 'Username and Password not accepted' with Gmail and SwiftMailer?. For more information, please follow other related articles on the PHP Chinese website!