Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Armghan's avatar

Gmail SMTP issue with Hosted Website but working on xampp

I get this error:

production.INFO: Failed to authenticate on SMTP server with username "[email protected]" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".

production.ERROR: Failed to authenticate on SMTP server with username "[email protected]" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". {"exception":"[object] (Symfony\\Component\\Mailer\\Exception\\TransportException(code: 535): Failed to authenticate on SMTP server with username \"[email protected]\" using the following authenticators: \"LOGIN\", \"PLAIN\". Authenticator \"LOGIN\" returned \"Expected response code \"235\" but got code \"535\", with message \"535 Incorrect authentication data\".\". Authenticator \"PLAIN\" returned \"Expected response code \"235\" but got code \"535\", with message \"535 Incorrect authentication data\".\". at /to/path/vendor/symfony/mailer/Transport/Smtp/EsmtpTransport.php:212)

The problem is that I don't get any issue and the emails are working on xampp but this only happens on my uploaded website. (Even worse, this has only recently started, maybe 15 days back and it was working before on uploaded website too)

0 likes
2 replies
Himmat's avatar
  1. Incorrect SMTP Credentials
  • Double-check the SMTP username and password for the production environment. It’s possible that incorrect credentials are being used. These may differ from your local setup, where you might be using different credentials.

  • Action: Verify the MAIL_USERNAME and MAIL_PASSWORD in the production .env file. Make sure they match exactly with your actual Gmail credentials.

  1. IP/Server Restrictions
  • Sometimes, the IP of the production server is blocked by Google because it sees the login attempt as suspicious (especially if the local environment is on a trusted home IP and the production server is on an unknown IP).

  • Solution: Log in to the Gmail account and check for security alerts. If you find any, confirm that the login attempt was you, and whitelist the production server's IP.

  1. Gmail SMTP Configuration Ensure that your .env configuration has the correct settings. Here’s an example of the correct configuration:
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=your_password_or_app_password
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

  1. SSL/TLS Issues
  • Gmail requires encryption to be used, and if there is a mismatch in encryption methods (e.g., SSL vs TLS), it might cause authentication issues.
  • Action: Ensure that you are using MAIL_ENCRYPTION=tls with port 587. If you use SSL, switch to MAIL_PORT=465 and MAIL_ENCRYPTION=ssl.
Armghan's avatar

@Himmat Thank you so much for the thorough reply!

  1. They are correct. I keep the same local and production variables. I am a one man team so I don't even need to replace and complicate my work for both env (Except for needful situations). The username is the email address used for logging into the gmail and the password was generated from the "App Passwords" portion (Since Non-Secure Login option is not available with 2FA). It's working local XAMPP, it should work in production cpanel.

  2. I didn't receive any security alert email. I don't see any other security section of the Google Account where it shows some login attempts either.

  3. SMTP Configs are exactly absolutely same.

  4. I've played around with the encryptions too, just to verify. No combination works. (It's configured correct):

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=smuacrrfmlrlqgsp
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
[email protected]

Anywhere I find similar issue threads, they keep mentioning the 2FA-UnsecureApps-AppPassword solution, which I know and I've already configured. Not to forget it's working on my XAMPP. I've talked to my hosting provider and they say they didn't put any SMTP restrictions from WHM.

Please or to participate in this conversation.