Errors

Username and Password not accepted: fixing Gmail SMTP login

Short answer

Username and Password not accepted is Gmail's 535-5.7.8 SMTP reply when your app logs in with credentials Google will not accept. The most common cause is using your normal Google password: SMTP needs an app password, which requires 2-Step Verification, or OAuth. App passwords also stop working when you change the account password. Nodemailer, PHPMailer, Django and other libraries all show the same Google text.

Last checked 16 November 2026

“Username and Password not accepted” is Gmail’s answer when your app logs in to smtp.gmail.com with credentials it will not take. Most of the time the username and password are right, but the password is the wrong kind: Google wants an app password or OAuth, not your account password.

535-5.7.8 Username and Password not accepted. For more information, go to
535 5.7.8  https://support.google.com/mail/?p=BadCredentials

In Nodemailer it appears as Invalid login: 535-5.7.8 Username and Password not accepted. with error code EAUTH. PHPMailer, Python’s smtplib, Django and Laravel print the same Google text inside their own messages.

What it means

535 with 5.7.8 is “Authentication credentials invalid” in RFC 4954. Google lists “Username and Password not accepted” in its SMTP error table. The connection and TLS worked; only the login failed, so no email was sent.

Why it happens

  • Your normal Google password. Apps that sign in with just a password are treated as less secure. Google’s guidance is to use “Sign in with Google” (OAuth) or an app password.
  • No 2-Step Verification. App passwords can only be created on accounts with 2-Step Verification turned on.
  • The account password changed. Google revokes all app passwords when the account password changes.
  • A typo or spaces. Copying the 16-character app password with spaces or a line break, or loading the wrong environment variable.
  • Wrong username. Use the full address, you@gmail.com or you@yourcompany.com.
  • Workspace admin settings. Your admin may block app passwords or SMTP for your organization.

How to fix it

  1. Turn on 2-Step Verification for the Google Account.

  2. Create an app password in your Google Account security settings and copy it without spaces.

  3. Use these settings:

    import nodemailer from 'nodemailer';
    
    const transport = nodemailer.createTransport({
      host: 'smtp.gmail.com',
      port: 465,
      secure: true,
      auth: { user: 'you@gmail.com', pass: process.env.GMAIL_APP_PASSWORD },
    });

    Port 587 with secure: false works too; Nodemailer upgrades with STARTTLS.

  4. Store it as a secret, not in code, and recreate it after any password change.

  5. For Google Workspace, ask your admin whether app passwords are allowed, or use OAuth or the Workspace SMTP relay.

  6. For production app email, move to a sending service with an API key. See Gmail SMTP settings for the limits.

Which server sent it

  • Gmail and Google Workspace send this exact text. Google’s table prints the code as 5.7.80; the live reply reads 5.7.8 as above. Related Google codes are 534 5.7.9 Application-specific password required (the table prints 5.7.90) and 534 5.7.14 Please log in through your web browser and then try again.
  • Microsoft 365 shows 535 5.7.3 Authentication unsuccessful or 535 5.7.139 instead. See SMTP error 535.
  • Yahoo also requires an app password for third-party apps and returns its own 535 text.
  • Generic servers say something like 535 5.7.8 Error: authentication failed (Postfix).

Quick checklist

Before you change anything else, confirm three things: the account has 2-Step Verification on, the password in your environment is the 16-character app password created after the last password change, and the username is the full email address. Those three cover nearly every case of this error.

Is it temporary?

No. It is a 5xx permanent reply: every retry with the same password fails, and too many failures can trigger 454 4.7.0 Too many sign-in attempts, try again later. Change the credential, then send again.

How Mailcandor handles it

Mailcandor’s SMTP relay uses smtp.mailcandor.com, username mailcandor and an API key as the password, so there is no personal password or 2-Step setup to break. Its API needs only a bearer key. When a message bounces, the deliverability coach explains it in plain English and hard bounces are suppressed automatically. Look up any reply with the free bounce code lookup, browse the error library, set up your domain with our SPF, DKIM and DMARC guide, and see the free tools.

Questions

Why does Gmail say Username and Password not accepted when they are correct?

Because Google does not accept your normal account password for SMTP from apps. Create an app password (2-Step Verification must be on) or use OAuth.

How do I fix this error in Nodemailer?

Set auth.user to the full Gmail address and auth.pass to a 16-character app password, with host smtp.gmail.com and port 465 (secure: true) or 587. Nodemailer reports the failure as an EAUTH error.

I can't find the app password option. Why?

Google says the option is missing when 2-Step Verification uses only security keys, when the account has Advanced Protection, or when it is a work or school account managed by an admin.

Should I send app email through a Gmail account?

It works for testing, but Gmail has daily sending limits and is tied to a person. A transactional email service with an API key is the better choice for production.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.