Home >Backend Development >PHP Tutorial >How to Resolve \'Expected Response Code 250 but Got Code 535\' SMTP Authentication Error?

How to Resolve \'Expected Response Code 250 but Got Code 535\' SMTP Authentication Error?

Linda Hamilton
Linda HamiltonOriginal
2024-10-18 17:57:03311browse

How to Resolve

Expected Response Code 250 but Received Code 535: Resolving SMTP Authentication Error

Upon attempting to send an email via SMTP through Gmail using SwiftMail, an error occurred indicating "Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted." This error stems from an authentication issue with the provided credentials.

To address this, enabling "access for lesser apps" and unlocking the Gmail captcha did not provide a resolution. However, implementing 2-step verification and creating an app password proved successful.

Solution:

  1. Enable 2-step verification for your Google account.
  2. Generate an app password. Select "Others (custom name)" and click "Generate."
  3. Update your .env file. Replace the previous Gmail password with the generated app password (in the MAIL_PASSWORD environment variable).
  4. Restart your Apache server to refresh the configuration changes.

After these steps, the email sending functionality should be restored. This solution eliminates the authentication error by utilizing a dedicated app password that grants access to your Gmail account.

The above is the detailed content of How to Resolve 'Expected Response Code 250 but Got Code 535' SMTP Authentication Error?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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