IMAP fails to connect to Office 365 with App Password
Steps to reproduce
- Have an Office 365 account with 2FA enabled
- Generate an App Password to be used with Nextcloud Mail
- Install Nextcloud Mail app
- Manually add an IMAP account with the expected office 365 settings
Expected behavior
IMAP should connect without issue and present the mail screen upon adding an account
Actual behavior
Authentication always seems to fail with the same message: Manual config failed. IMAP username or password is wrong.
Upon enabling debug, the horde_imap.log shows the following (username redacted):
Thu, 01 Sep 2022 18:20:02 +0000 Connection to: imap://outlook.office365.com:993/ Server connection took 0.0804 seconds. S: * OK The Microsoft Exchange IMAP4 service is ready. [QgBZAEEAUABSADAANgBDAEEAMAAwADEAMAAuAG4AYQBtAHAAcgBkADAANgAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A] C: 1 CAPABILITY S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+ S: 1 OK CAPABILITY completed. Command 1 took 0.0193 seconds. C: 2 AUTHENTICATE PLAIN [INITIAL CLIENT RESPONSE (username: [email protected])] S: 2 NO AUTHENTICATE failed. Command 2 took 2.2191 seconds.
Mail app version
1.13.8
Mailserver or service
Office 365 IMAP
Operating system
Debian 11, Docker Nextcloud AIO 1.7.1
PHP engine version
No response
Web server
No response
Database
No response
Additional info
No response
Related: https://github.com/nextcloud/mail/issues/6591. Though I hope that is not in effect yet.
I'm closing this issue as app passwords have been discontinued and XOAUTH2 was implemented.