Concepts & troubleshooting

SMTP authentication checker — fix error 535

Fix SMTP error 535 5.7.8 "username and password not accepted". App passwords, API-key vs SMTP credentials, username format, and how to confirm it is auth.

11 min read Credentials redacted No signup

A 535 response (typically 535 5.7.8 "Username and Password not accepted" or 535 Authentication credentials invalid) means the SMTP session connected, EHLO and STARTTLS succeeded, but the server rejected your credentials during the AUTH command. It is an authentication problem, not a connection or relay issue. Changing ports or switching TLS modes will not help because those steps already passed.

How to confirm it is a 535

Run your test in SMTP Tester and read the live transcript:

  1. Look for a successful 220 greeting (connection is fine).
  2. Confirm 250 responses after EHLO (server capabilities exchanged).
  3. If using STARTTLS, look for 220 Ready to start TLS (encryption is fine).
  4. The AUTH PLAIN or AUTH LOGIN command appears, followed immediately by 535.

If the transcript shows these steps clearly, your issue is credentials. Because SMTP Tester redacts passwords and AUTH payloads, you can safely paste the transcript into a support ticket or team chat.

What AUTH looks like on the wire

Understanding the wire format explains a class of 535 errors that have nothing to do with wrong credentials. SMTP AUTH (RFC 4954) sends credentials as base64, and the two common mechanisms differ in how much goes out at once.

AUTH PLAIN sends the username and password in a single base64 string in one command:

C: AUTH PLAIN AGpvaG5AZXhhbXBsZS5jb20Ac2VjcmV0MTIz
S: 235 2.7.0 Accepted

The decoded payload is three NUL-separated fields: authorization-id NUL authentication-id NUL password. Servers ignore the authorization ID, so clients send an empty first field.

AUTH LOGIN is a two-step prompt. The server asks for the username, then the password; the client answers each with a separate base64 line:

C: AUTH LOGIN
S: 334 VXNlcm5hbWU6
C: am9obkBleGFtcGxlLmNvbQ==
S: 334 UGFzc3dvcmQ6
C: c2VjcmV0MTIz
S: 235 2.7.0 Accepted

The 334 responses are base64 too: VXNlcm5hbWU6 decodes to Username: and UGFzc3dvcmQ6 to Password:.

Why a trailing newline or space breaks auth

Base64 decodes the entire line you send. If your password variable contains a trailing newline (from a shell heredoc or a read command), the client base64-encodes secret123\n instead of secret123. Those are different byte sequences, so the server computes a different hash and returns 535 even though the password on screen looks correct. The same applies to a trailing space from a copy button, a carriage return (\r) from a Windows-edited config file, and quoting that preserves whitespace.

A quick check in a terminal: printf '%s' "$SMTP_PASS" | wc -c shows the exact byte count, including invisible characters. Compare it to the length in the provider dashboard.

Auth-related SMTP response codes

A 535 is one member of a family of AUTH responses. The exact code tells you which layer failed:

Code Typical text Meaning First fix to try
235 2.7.0 Accepted Auth succeeded Not an error; the problem lies elsewhere
334 base64 prompt Server is asking for username or password Normal mid-AUTH exchange, no action
501 Syntax error in parameters Malformed AUTH command, often broken base64 or an unsupported mechanism Check the mechanism and client encoding
530 5.7.0 Authentication required You sent mail without authenticating at all Enable SMTP AUTH in your client
534 5.7.9 Authentication mechanism is too weak (or app-password variants) Server rejects the mechanism or demands a stronger credential Generate an app password; use a mechanism the server advertises
535 5.7.8 Authentication credentials invalid Username or password is wrong for this server Verify credential type, username format, and hidden whitespace
538 5.7.11 Encryption required for requested authentication mechanism Server refuses to authenticate on a plaintext connection Use STARTTLS (port 587) or implicit TLS (port 465)
454 4.7.0 TLS not available due to temporary reason TLS handshake failed or auth is throttled Retry later; check TLS negotiation

Two of these are easy to confuse with 535:

If your test fails before AUTH entirely, the problem is at a different layer. See what an SMTP test covers and port 587 vs 465 if the failure is in TLS negotiation.

Most common causes

1. Missing app password (2-Step Verification)

Gmail, Microsoft 365, Yahoo, and iCloud block basic password authentication once 2-Step Verification (2FA) is enabled on the account. They require a generated app-specific password instead of your normal login password.

If 2FA is not enabled, the normal password may still work (Google calls this "less secure app access"), but this is deprecated. Use app passwords regardless.

2. Wrong credential type (API key vs SMTP password)

Many providers issue separate credentials for their REST API and SMTP interface; using the wrong one causes 535:

Provider SMTP Username SMTP Password
SendGrid apikey (literal string) SendGrid API key with Mail Send permission
Resend resend (literal string) Resend API key
SparkPost SMTP_Injection (literal string) API key with SMTP permission
Mailgun postmaster@your-domain.com Domain SMTP password (not the private API key)
Brevo SMTP login email (from Settings → SMTP) SMTP key (not the v3 API key)
Postmark Server API token Server API token (same for both)
Mailjet API key Secret key

If you paste a REST API key into the SMTP password field (or vice versa), you get 535 even though the credential is valid, just for the wrong interface. Keys with the wrong scope fail the same way: a SendGrid key without Mail Send permission fails SMTP auth like an invalid key.

3. Wrong username format

Some providers require the full email address; others expect a fixed string or account-specific ID:

Providers in the "literal string" family (SendGrid, Resend, SparkPost) confuse people most. The username never changes; all identity is carried by the key in the password field. Pasting your account email into the username field for one of these gets you 535 every time.

4. Truncated or mangled password

Long API keys (SendGrid keys are ~69 characters, SES SMTP passwords are ~44) get truncated when copy-pasted across terminals, email clients, or config files. Common issues:

Fix: paste into a plain-text editor, confirm the full length, then copy into your SMTP client.

5. Wrong auth method

Some servers support only specific AUTH mechanisms:

If Auto-detect fails, set the auth method explicitly in SMTP Tester to match what the server advertises in its EHLO response (look for 250-AUTH PLAIN LOGIN or similar in the transcript). If the server advertises no AUTH line at all, it does not accept authentication on that port and no credentials will work.

Less common causes

Account suspended or locked

If the account was disabled for abuse, billing, or inactivity, auth will fail with 535 even though the credentials are correct. Some providers return a generic "credentials invalid" for locked accounts so attackers cannot probe account status. Check your provider dashboard for alerts and confirm the account has not exceeded its sending quota.

IP-based restrictions

Some providers (Mailgun, enterprise setups) restrict SMTP access to whitelisted IPs. Even with correct credentials, connections from non-whitelisted IPs get 535. Add your IP to the allowlist in the provider's settings, and remember: if you test from a laptop on one network and your app runs from a server or CI environment on another, the allowlist that works in one place fails in the other.

Rate-limited authentication

After too many failed AUTH attempts, some servers temporarily block further attempts from your IP. The response may be a 454 or a 535 with "too many invalid login attempts" in the text. This is where debugging goes wrong: you fix the credential problem, retry, and still fail because the temporary block is active. Wait 15–60 minutes before retrying.

OAuth2 required

Microsoft 365 is deprecating basic auth for SMTP in favor of OAuth2 (XOAUTH2). If basic auth is disabled for your tenant, no username/password combination will work; you need an OAuth2 token. Check the "SMTP AUTH" policy in your admin center; it can be disabled tenant-wide or per-mailbox.

A debugging checklist, cheapest first

Work down this list in order; most 535s are resolved before step 5.

  1. Read the transcript. Confirm the failure is at AUTH (535/534), not earlier. Providers often embed a hint in the text.
  2. Check whitespace. Re-enter the password by hand or trim the variable. Costs 30 seconds, fixes many cases.
  3. Verify the username format against the tables above. For SendGrid, Resend, and SparkPost that means a literal string.
  4. Confirm credential type. SMTP credential vs REST API key vs key with the wrong scope.
  5. Generate an app password if 2FA is on (Gmail, Microsoft, Zoho, Yahoo, iCloud).
  6. Pin the auth mechanism to what the EHLO response advertises.
  7. Check account state: active subscription, not locked, not out of quota.
  8. Check IP allowlists and test from the network that will send production mail.
  9. Wait out any auth rate limit, then retry once.
  10. Reset the credential entirely. If a brand-new credential fails from a clean client, the problem is policy (IP block, tenant policy, account state).

Related errors

Provider-specific fixes

A 535 is the same failure everywhere, but the correct credential differs per provider. Check the guide for yours before retrying:

Frequently asked questions

Does 535 always mean the password is wrong?

No. It means the server rejected the authentication attempt. The password may be correct but the wrong type (API key vs SMTP key), the account may be locked or out of quota, your IP may not be allowlisted, or the tenant may have disabled basic auth. The transcript's message text usually distinguishes these.

Why does my password work in one client but fail in another?

Whitespace and encoding. Some clients trim input fields; others send exactly what you typed, including a trailing space or newline. Config loaders differ too: some strip quotes from dotenv values, some keep them. Compare the credential's byte count in both places.

Can I use my normal Gmail password for SMTP?

Only if 2-Step Verification is off and "less secure app access" is still allowed, which Google is phasing out. With 2FA on, you must use a 16-character app password; the account password never works for SMTP once 2FA is enabled.

What is the difference between 530 and 535?

530 means you did not authenticate at all; the server required AUTH before MAIL FROM and none was attempted. 535 means authentication was attempted and the credentials were rejected. If you see 530, fix your client configuration.

Why does the transcript show base64 gibberish instead of my username?

AUTH transmits credentials base64-encoded, so the transcript shows encoded strings during the exchange. SMTP Tester redacts these payloads (and passwords) before display, so a 334 prompt followed by a redacted line is expected.

I fixed the credentials but still get 535. What now?

You may be inside a temporary auth rate limit from the earlier failed attempts, or behind an IP allowlist that does not include your test network. Wait, then retest from the network that will send production mail. If a fresh credential still fails from a clean client, the cause is account or policy state.

Try it on your own server

Run these settings against your SMTP server and watch the live, credential-redacted protocol transcript.

Open SMTP Tester