“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.comoryou@yourcompany.com. - Workspace admin settings. Your admin may block app passwords or SMTP for your organization.
How to fix it
-
Turn on 2-Step Verification for the Google Account.
-
Create an app password in your Google Account security settings and copy it without spaces.
-
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: falseworks too; Nodemailer upgrades with STARTTLS. -
Store it as a secret, not in code, and recreate it after any password change.
-
For Google Workspace, ask your admin whether app passwords are allowed, or use OAuth or the Workspace SMTP relay.
-
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) and534 5.7.14 Please log in through your web browser and then try again. - Microsoft 365 shows
535 5.7.3 Authentication unsuccessfulor535 5.7.139instead. 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.