I have Office 365 Business Essentials with a single user. I have enabled IMAP access in Exchange Admin Center for this user's mailbox.
I have 2 factor authentication enabled on the account and have generated an app password.
I'm using the settings listed in my outlook 'Sync email' settings:
outlook.office365.com
port 993
I am using my username me@example.com
and my app password (xxx) however my login fails. e.g.
$ openssl s_client -connect outlook.office365.com:993 -crlf
CONNECTED(00000005)
<snip>
* OK The Microsoft Exchange IMAP4 service is ready. [...]
a001 login me@example.com xxx
a001 NO LOGIN failed.