JShermanREX
Through modifying the code (look in include/class.email.php -> MailBoxAccount::getMailbox(), include/class.mail.php -> MailBoxProtocolTrait::init(), and even include/laminas-mail/src/Protocol/Imap.php) or inspecting your server’s network traffic. Sometimes the errors can be misleading as they can be generalized for certain exceptions/errors.
To check the auth attempts on Microsoft’s end (which is the easiest route) Google says:
1. Login to Microsoft Entra Admin Center as global or security admin
2. Navigate to Identity > Monitoring & health > Sign-in logs
3. Switch to the Non-interactive user sign-in logs tab (since IMAP/POP requests typically register as non-interactive).
4. Filter or search by the affected User or check the Client app column for protocols like IMAP or Authenticated SMTP.
You said you confirmed IMAP succeeds using OAuth2 with the service account address, right? So you setup the auth, got a working token (confirmed in Token tab in the auth Config popup), setup the hostname/port number, set the Status to Enable, and Saved Changes successfully? Of so then that would rule out host connection issues, likely firewall issues, port restrictions, etc.
Did you add the proper Graph - delegated permissions including imap, offline_access, and the others and then provide admin consent to all of them in the app registration in azure?
You confirmed IMAP is enabled on the shared mailbox in outlook and via the admin center? You also ensured there are zero IMAP restrictions on the shared mailbox from the admin-side?
Cheers.