
I only just discovered "davmail" which can be helpful in situations like this. davmail is a server/gateway that you run on your local machine that knows how to talk to Exchange or Office 365 mail servers, and which provides local ports for IMAP, POP, and SMTP. And, it knows how to handle interactive two-factor authentication. So you can use any IMAP mail client (thunderbird, mutt, whatever) however you wish. My use case is that I like using the mutt mail client, which talks IMAP, but does not know how to talk to Exchange. So, I run davmail, set davmail to use "O365Interactive" authentication, and tell mutt to connect to imap://localhost:1143/INBOX and tell it my email address. Mutt prompts me for my password, then davmail pops up a microsoft style two factor authentication window, I put in my authenticator code, and read and reply to mail, save locally, do whatever. And davmail will cache an oauth (or other?) token, so I don't have to deal with multi-factor authentication every time. I use this to connect to the O365 email service for an Ontario educational institution that does not provide IMAP access and which requires multi-factor authentication. So far, so good. Hope this is useful. John