IMAP: [AUTHENTICATIONFAILED] Invalid credentials Email / SMTP Origin: Network Last updated 4 Nov 2026

IMAP: NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)

The IMAP server rejected the login — wrong password, IMAP disabled, an app password required, or basic auth blocked.

Exact message you may see [AUTHENTICATIONFAILED] Invalid credentials (Failure)imaplib.IMAP4.error: b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)'NO [AUTHENTICATIONFAILED] Authentication failedIMAP login failed AUTHENTICATIONFAILEDLOGIN failed. Authentication failed
Seen on: SMTP Python

Meaning

Mail clients and scripts (imaplib, Thunderbird) show this when credentials fail. For Gmail enable IMAP and use an app password or OAuth; for Microsoft 365 basic auth over IMAP is disabled, so OAuth is required. Dovecot servers log the real reason (auth failed, reason=...).

Common causes

  • Wrong password/username
  • IMAP access disabled for the account
  • 2-Step Verification with normal password used
  • Provider disabled basic auth (Microsoft 365)
  • Account locked after repeated failures

⚡ Quick fix

  1. Enable IMAP in the mailbox settings
  2. Use an app password or switch to OAuth 2.0
  3. Check server logs: grep -i "auth failed" /var/log/mail.log

Detailed fix by platform

Python

  1. import imaplib; m = imaplib.IMAP4_SSL("imap.gmail.com"); m.login(user, app_password) raises imaplib.IMAP4.error: [AUTHENTICATIONFAILED] on failure

How to diagnose

  1. User — Full address?
  2. Password — App password/OAuth?
  3. IMAP — Enabled for the account?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

530 5.7.0 Authentication Required — SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required (Email / SMTP)530 5.7.0 Authenticat…534 5.7.9 Application-specific password required — SMTP: 534-5.7.9 Application-specific password required. Learn more at https://support.google.com/accounts/answer/185833 (Email / SMTP)534 5.7.9 Application…535 5.7.8 Username and Password not accepted — SMTP: 535-5.7.8 Username and Password not accepted. Learn more at https://support.google.com/mail/?p=BadCredentials (Email / SMTP)535 5.7.8 Username an…DKIM: body hash did not verify — DKIM: dkim=fail (body hash did not verify) / signature verification failed (Email / SMTP)DKIM: body hash did n…DMARC fail: SPF and DKIM not aligned — DMARC: dmarc=fail (p=REJECT) — SPF and DKIM pass but domains are not aligned with the From header (Email / SMTP)DMARC fail: SPF and D…IMAP: Too many simultaneous connections — IMAP: NO [ALERT] Too many simultaneous connections. (Failure) (Email / SMTP)IMAP: Too many simult…SmtpClientAuthentication is disabled for the Tenant — SMTP: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled / SmtpClientAuthentication is disabled for the Tenant (Email / SMTP)SmtpClientAuthenticat…SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client — Laravel: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client [caching_sha2_password] (Laravel)SQLSTATE[HY000] [2054…IMAP: [AU…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.