IMAP XOAUTH2 returns "User is authenticated but not connected" for a single Outlook.com account — other accounts work fine

huang huan 0 Reputation points
2026-09-16T02:46:41.3833333+00:00

I have a Java backend application using JavaMail (javax.mail 1.6.7) to pull emails from Outlook.com consumer mailboxes via IMAP with OAuth2 (XOAUTH2). One specific mailbox started failing a few days ago with the error "User is authenticated but not connected." Other Outlook.com mailboxes work perfectly with the exact same code and configuration. No code or configuration changes were made.

Configuration:

  • IMAP server: outlook.office365.com, port 993, SSL/TLS
  • SMTP server: smtp.office365.com, port 587, STARTTLS
  • Authentication: XOAUTH2 (OAuth2)
  • Token endpoint: https://login.microsoftonline.com/consumers/oauth2/v2.0/token
  • Scope: https://outlook.office.com/SMTP.Send https://outlook.office.com/Mail.ReadWrite https://outlook.office.com/Mail.Read https://outlook.office.com/IMAP.AccessAsUser.All offline_access
  • Account type: consumer Outlook.com (personal)

Key findings:

  1. Same OAuth2 access token works for SMTP but fails for IMAP — SMTP AUTH XOAUTH2 succeeds, proving the token is valid
  2. CAPABILITY returns LOGINDISABLED — see IMAP log below
  3. 4 consecutive retries all fail — not intermittent
  4. Other Outlook.com mailboxes work fine with the same code and config
  5. Mozilla Thunderbird with OAuth2 also fails on the same account
  6. Outlook Web Access (outlook.live.com) works fine — can log in and send/receive emails normally
  7. IMAP is enabled in Outlook web settings
  8. No code or configuration changes were made — this account worked fine until a few days ago

IMAP protocol log (redacted):


* OK Microsoft Exchange IMAP4 service ready. (tcpproxy/15.21.0406.000 BACKENDAUTHENTICATE)

A0 CAPABILITY

* CAPABILITY IMAP4 IMAP4rev1 AUTH=XOAUTH2 LOGINDISABLED SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+

A0 OK CAPABILITY completed.

AUTHENTICATE XOAUTH2

A1 NO User is authenticated but not connected.

(retried 4 times: A1, B1, C1, D1 — all return the same error)

SMTP protocol log (redacted, for comparison — this succeeds):


220 Microsoft ESMTP MAIL Service ready

EHLO [redacted]

250-SIZE 157286400

250-STARTTLS

250 AUTH LOGIN XOAUTH2

STARTTLS

220 2.0.0 SMTP server ready

AUTH XOAUTH2

AUTH XOAUTH2 succeeded    ← SMTP succeeds with the same token

Error stack trace:


javax.mail.AuthenticationFailedException: User is authenticated but not connected.

    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:708)

    at javax.mail.Service.connect(Service.java:342)

    at javax.mail.Service.connect(Service.java:222)

Question:

Has anyone encountered this issue where a single Outlook.com consumer account returns "User is authenticated but not connected" for IMAP while SMTP works fine with the same token? Is this an account-level IMAP restriction on the server side? How can this be resolved?

Outlook | Web | Outlook.com | Email
0 comments No comments

1 answer

Sort by: Newest
  1. Hendrix-V 19,115 Reputation points Microsoft External Staff Moderator
    2026-09-16T06:44:58.46+00:00

    Hi huang huan,

    Based on your testing, it’s notable that the same OAuth token works successfully with SMTP while IMAP returns "User authenticated but not connected", and the behavior is isolated to a single Outlook.com account. The fact that another mail client reproduces the same result also suggests the issue is not limited to your JavaMail implementation.

    As I have checked and validated, these steps from AI answer are pointing us at the right direction:

    1. Sign in to your Microsoft account and review Recent Activity for any unusual or blocked sign-in events related to IMAP access.
    2. Verify that IMAP access remains enabled in your Outlook.com mail settings.

    If both checks look correct, try testing again with a newly acquired access token to rule out a temporary authentication state.

    If the issue continues and other Outlook.com accounts work normally with the same application and configuration, the remaining evidence points toward a condition specific to this mailbox's IMAP access rather than the client configuration itself.

    At that stage, it may be worth contacting Microsoft Support for further account-specific investigation, as there may not be any additional client-side changes available to test.

    Please note that this is a user-to-user support forum. Moderators, contributors including external Microsoft employees cannot directly intervene in Microsoft product features or access back-end systems. Our role is limited to providing technical guidance on reported issues, requests, or ideas.

    I understand how frustrating it can be when a configuration that previously worked suddenly affects only one account. Let me know if you need further assistance, feel free to ask me by clicking "Add Comment" or "Add Answer" if you cannot add comment so your response will be visible. Thanks for your effort.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.