Exchange Connection Problems

Fix IMAPS Authentication Failure for a Microsoft 365 Mailbox

Aamir Naveed AkramAamir Naveed Akram Nov 20, 2026 868 views

Question details

Resolve an authentication failure when a JavaMail application connects to a Microsoft 365 mailbox over IMAPS.

Fix IMAPS Authentication Failure for a Microsoft 365 Mailbox
Product
Exchange Online and JavaMail
Device & OS
not provided
Scenario
A JavaMail application connects to an Office 365 mailbox using IMAPS.
Observed behavior
The server returns the error A1 NO AUTHENTICATE failed.
Before you start

Confirm the affected mailbox address and whether the application uses a password or an OAuth 2.0 access token. You may need an Exchange administrator to check mailbox settings and an Entra administrator to review app permissions.

Solution 1Recommended

Configure OAuth 2.0 for the JavaMail IMAPS connection

Use this approach when the application sends a username and password or has an invalid OAuth configuration.

Exchange Online no longer supports Basic authentication for IMAP. The application must use a supported OAuth 2.0 flow; an app password is not a substitute.

The steps below describe delegated access, where a user signs in. App-only access requires different Exchange permissions and configuration.

1
Register the application

In the Microsoft Entra admin center, open Identity > Applications > App registrations and select New registration, or open the existing registration.

2
Add IMAP permission

In the registration, open API permissions > Add a permission, select Office 365 Exchange Online, and add the delegated IMAP.AccessAsUser.All permission. Grant consent as required by your organization.

3
Acquire an access token

Use the Microsoft identity platform OAuth flow to sign in the mailbox user and request the https://outlook.office.com/IMAP.AccessAsUser.All scope. Supply the resulting access token to JavaMail, not the user's password.

4
Connect with XOAUTH2

In the JavaMail connection settings, use outlook.office365.com on port 993 with SSL enabled. Set mail.imaps.auth.mechanisms to XOAUTH2, then connect using the mailbox address as the username and the access token as the credential.

Configure OAuth 2.0 for the JavaMail IMAPS connection
Check token scope and expiration: If authentication still fails, obtain a fresh token and verify that it is intended for Exchange Online and includes the delegated IMAP permission.
Free Microsoft Office alternative

Use WPS Office for Microsoft Office documents

WPS Office is a free, lightweight alternative for working with Office documents in a familiar interface. Its format compatibility helps you move between office suites, but it does not fix Exchange Online or JavaMail authentication.

Open and edit Microsoft Office formats including DOCX, XLSX, and PPTXUse a familiar interface for documents, spreadsheets, and presentationsWork with Office files without changing the Exchange mailbox configurationMove existing documents into a lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

What server and port should I use for Exchange Online IMAPS?

Use outlook.office365.com on TCP port 993 with SSL/TLS enabled. Configure the client to authenticate with OAuth 2.0.

Can I use my Microsoft 365 password to authenticate JavaMail over IMAP?

No. Exchange Online no longer supports Basic authentication for IMAP. Configure JavaMail to use XOAUTH2 with an OAuth 2.0 access token.

Where can an administrator enable IMAP for a mailbox?

In the Exchange admin center, open Recipients > Mailboxes, select the mailbox, and go to Mail > Manage email apps. Enable IMAP and save the change.

Does an AUTHENTICATE failed response mean port 993 is blocked?

Usually not: the response generally indicates that the client reached the server. Check the OAuth token, application permissions, and mailbox IMAP settings; test port 993 separately if needed.