DavMail is a tool that can be used to bridge Microsoft email accounts (such as UWaterloo.ca email) to IMAP, enabling the user to use third-party email clients.
On Arch: DavMail is available through the AUR.
On Debian: sudo apt install davmail
From Flathub: flatpak install flathub org.davmail.DavMail
On Linux: See http://davmail.sourceforge.net/linuxsetup.html
On macOS: See http://davmail.sourceforge.net/macosxsetup.html
On Windows: See http://davmail.sourceforge.net/windowssetup.html
You should be able to use any email client that supports IMAP. This guide assumes that you're running your email client on the same device as DavMail.
When you first run DavMail, it will launch a menu allowing you to configure the gateway.
Change the Exchange Protocol to O365Interactive. This will enable you to authenticate with 2FA. Save this change.
Now, open your email client and set up your email account.
Fill in your information, using your @uwaterloo.ca email address. You will need to manually configure the server details with something like the following:
Incoming server:
Outgoing server:
Attempt to log in. Your email client may complain that you're making an unencrypted connection. This is fine because you're just connecting on localhost (i.e., not sending data over a network). If you're running DavMail on a server, make sure to change this setup accordingly.
DavMail will now open a dialog asking the user to authenticate with Office. Click the link to open it in your browser.
This will open a UWaterloo login page. Sign in as usual, completing the Duo 2FA.
If this is your first time connecting DavMail to your account, Microsoft will ask if you want to grant permission for it to act as a third-party app. Accept this request.
You will be redirected to a blank page. Copy the URL from your URL bar. It contains the OAuth2 code needed for DavMail to authenticate.
Paste this URL into the DavMail window and click OK.
Go back to your email client and try again to log in. This time, you should log in successfully!