A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
Based on the details provided, I understand that your Java application using MSAL4J and Jakarta Mail is failing to open the "INBOX" folder for a newly created mailbox, specifically throwing the exception: "A3 BAD User is authenticated but not connected." This behavior occurs despite successful token retrieval and folder connection, while your older mailboxes continue to function normally.
This behavior can sometimes occur under certain conditions where the XOAUTH2 authentication is successful, but the IMAP server cannot attach the session to a valid mailbox or allow mailbox operations immediately following authentication.
In many scenarios, older mailboxes function normally because IMAP was historically enabled at a time when application passwords were still permitted. However, mailboxes created under modern security defaults or updated tenant policies often have the IMAP protocol disabled by default. The restriction you observed regarding application passwords is a related symptom, indicating that the tenant has likely restricted legacy authentication protocols.
Let's walk through several checks to ensure the mailbox is properly provisioned and accessible:
Confirm that the new mailbox has been fully provisioned in Exchange Online and has a valid license assigned. In some scenarios, a mailbox that is not fully initialized may allow authentication but fail to connect to the underlying folder structure.
We need to ensure that IMAP is explicitly enabled for the new account and is not being blocked by a policy. Even if you can connect and retrieve the folder object, the server will drop the session during the open stage if the protocol is restricted. Please verify the following:
- IMAP is enabled at the Tenant level.
- IMAP is enabled at the individual Mailbox level in the Exchange Admin Center.
Review your environment for any Conditional Access or Authentication Policies that might be blocking "legacy protocols." Even when using modern OAuth, certain security configurations may still restrict the IMAP protocol itself.
Confirm that MSAL4J is requesting the token with the correct resource and scopes. For a delegated user token, it is recommended to request scopes specifically for the Outlook/Exchange resources such as IMAP.AccessAsUser.All, SMTP.Send với Outlook/Exchange resource.
As a moderator, I don’t have access to your exact environment or system configuration, so I can only provide general guidance based on documented behavior. Given the nature of this issue, and the fact that it varies by system setup, you may benefit from posting the question on GitHub or a development‑focused forum where engineers who work directly with Access Runtime and version‑compatibility scenarios can offer more targeted help.
Thank you for your understanding.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.