Fix IMAPS Authentication Failure for a Microsoft 365 Mailbox
Question details
Resolve an authentication failure when a JavaMail application connects to a Microsoft 365 mailbox over IMAPS.

- 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.
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.
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.
In the Microsoft Entra admin center, open Identity > Applications > App registrations and select New registration, or open the existing registration.
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.
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.
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.

Verify that IMAP is enabled for the mailbox
Check mailbox access if the OAuth configuration is correct but the account still cannot authenticate.
Check IMAPS connectivity and test another client
Use a connection test to rule out a network block or a problem specific to the JavaMail application.
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.

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.




