Office 365: OAuth 2.0 IMAP, POP3 email client connectivity tools
To assist IT managers in resolving Office 365 connectivity issues, Microsoft offers a web-based connectivity analyzer. It works with POP3 or IMAP clients and OAuth 2.0:
Test IMAP access:
https://testconnectivity.microsoft.com/tests/O365Imap/input
Test POP3 access:
https://testconnectivity.microsoft.com/tests/O365Pop/input
Those tools test IMAP and POP3 connectivity only – remember that application in your AD must be properly configured.
You need to choose and implement one of the available OAuth 2.0 flows:
https://www.limilabs.com/blog/office-365-basic-auth-is-disabled