SMTP error: could not authenticate

Created on 16 April 2025, about 1 month ago

Problem/Motivation

I made the module settings and my Gmail credentials are correct, and yet I'm getting SMTP error: could not authenticate. What am I doing wrong? The smtp server is smtp.gmail.com, the port is 465 (I tried 587 as well), I selected SSL for 465 and TLS for 587.

💬 Support request
Status

Active

Version

2.3

Component

Miscellaneous

Created by

🇹🇷Turkey Kartagis Istanbul

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Kartagis
  • 🇦🇺Australia imclean Tasmania

    Under "Debug level" select "Full communication.

    Your username is your full email address and your password is case sensitive.

  • 🇮🇳India aneehD Punjab

    Hi @kartagis

    Are you using 2-Step Verification (2FA/MFA) on your Gmail account? If so, you can try to generate an App Password to use with SMTP, as per given guidelines at https://support.google.com/accounts/answer/185833

  • 🇹🇷Turkey Kartagis Istanbul

    @aneehd No I'm not using 2FA.
    @imclean I'll try that tomorrow and repport back.

  • 🇦🇺Australia imclean Tasmania

    Are you using Basic authentication? Your Gmail account may require OAuth2.

  • 🇹🇷Turkey Kartagis Istanbul
    2025-05-04 11:19:36 Connection: opening to ssl://smtp.gmail.com:465, timeout=30, options=array ( 'ssl' => array ( 'verify_peer' => true, 'verify_peer_name' => true, 'allow_self_signed' => false, ),)
    2025-05-04 11:19:36 Connection: opened
    2025-05-04 11:19:36 SMTP INBOUND: "220 smtp.gmail.com ESMTP 4fb4d7f45d1cf-5fa7781cffdsm3829476a12.46 - gsmtp"
    2025-05-04 11:19:36 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 4fb4d7f45d1cf-5fa7781cffdsm3829476a12.46 - gsmtp
    2025-05-04 11:19:36 CLIENT -> SERVER: EHLO dev-tarcinaym.lndo.site
    2025-05-04 11:19:36 SMTP INBOUND: "250-smtp.gmail.com at your service, [95.7.5.125]"
    2025-05-04 11:19:36 SMTP INBOUND: "250-SIZE 35882577"
    2025-05-04 11:19:36 SMTP INBOUND: "250-8BITMIME"
    2025-05-04 11:19:36 SMTP INBOUND: "250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
    2025-05-04 11:19:36 SMTP INBOUND: "250-ENHANCEDSTATUSCODES"
    2025-05-04 11:19:36 SMTP INBOUND: "250-PIPELINING"
    2025-05-04 11:19:36 SMTP INBOUND: "250-CHUNKING"
    2025-05-04 11:19:36 SMTP INBOUND: "250 SMTPUTF8"
    2025-05-04 11:19:36 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [95.7.5.125]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    2025-05-04 11:19:36 Auth method requested: UNSPECIFIED
    2025-05-04 11:19:36 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
    2025-05-04 11:19:36 Requested auth method not available:
    2025-05-04 11:19:36 Auth method selected: LOGIN
    2025-05-04 11:19:36 CLIENT -> SERVER: AUTH LOGIN
    2025-05-04 11:19:36 SMTP INBOUND: "334 VXNlcm5hbWU6"
    2025-05-04 11:19:36 SERVER -> CLIENT: 334 VXNlcm5hbWU6
    2025-05-04 11:19:36 CLIENT -> SERVER: dG9sZ2FAb3pzZXMubmV0
    2025-05-04 11:19:37 SMTP INBOUND: "334 UGFzc3dvcmQ6"
    2025-05-04 11:19:37 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
    2025-05-04 11:19:37 CLIENT -> SERVER: akprN2JVbmcyZGJCSzdl
    2025-05-04 11:19:37 SMTP INBOUND: "535-5.7.8 Username and Password not accepted. For more information, go to"
    2025-05-04 11:19:37 SMTP INBOUND: "535 5.7.8 https://support.google.com/mail/?p=BadCredentials 4fb4d7f45d1cf-5fa7781cffdsm3829476a12.46 - gsmtp"
    2025-05-04 11:19:37 SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. For more information, go to535 5.7.8 https://support.google.com/mail/?p=BadCredentials 4fb4d7f45d1cf-5fa7781cffdsm3829476a12.46 - gsmtp
    2025-05-04 11:19:37 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. For more information, go to535 5.7.8 https://support.google.com/mail/?p=BadCredentials 4fb4d7f45d1cf-5fa7781cffdsm3829476a12.46 - gsmtp
    SMTP error: Could not authenticate.
    2025-05-04 11:19:37 CLIENT -> SERVER: QUIT
    2025-05-04 11:19:37 SMTP INBOUND: "221 2.0.0 closing connection 4fb4d7f45d1cf-5fa7781cffdsm3829476a12.46 - gsmtp"
    2025-05-04 11:19:37 SERVER -> CLIENT: 221 2.0.0 closing connection 4fb4d7f45d1cf-5fa7781cffdsm3829476a12.46 - gsmtp
    2025-05-04 11:19:37 Connection: closed
  • 🇹🇷Turkey Kartagis Istanbul

    @imclean do you mean drupal/oauth2? Because it doesn't have a stable version.

  • 🇦🇺Australia imclean Tasmania

    I mean Google may require OAuth2:

    Are you using your full email address as the username?

    do you mean drupal/oauth2? Because it doesn't have a stable version.

    Whether to use it or not is up to you, that's not something I can help you with.

    That said, it looks like there is a stable release, as well as a module on Github which integrates the OAuth2 module with PHPMailer SMTP.

  • 🇹🇷Turkey Kartagis Istanbul

    Yes, I am using my full e-mail address, but what I'm wondering is if the reason could be that I am using my own domain on Gmail, which is on Google Workspace.

  • 🇦🇺Australia imclean Tasmania

    That shouldn't make a difference. To start with, have a look at the information in the links I posted. This isn't an issue with the module itself.

Production build 0.71.5 2024