negative zero

Using Thunderbird with Outlook email

2022 July 17

[email] [tech] [tutorial]


2022 August 28 Update: I just learned I can do this without davmail by just setting the authentication method to OAuth2. See How to Configure Thunderbird for Office 365 Using IMAP (Oauth2).


Two days ago, I wrote about setting up Evolution with my school email because I couldn't figure out how to get Thunderbird working.

Today, I figured out how to get Thunderbird working.

In this setup, Thunderbird connects to davmail (running locally, though I'd like to set it up on my server at some point), which in turn connects to Microsoft Outlook.


1. Install Thunderbird and davmail

Unfortunately, davmail is not available in the Fedora repos, so I set it up on Debian:

sudo apt install thunderbird davmail


2. Set up Thunderbird with davmail

When you first run davmail, it will launch a menu like the one below.

davmail settings

Change the Exchange Protocol to O365Interactive. If you don't do this, davmail will be unable to authenticate with 2FA.

the same menu, but the exchange protocol has been set to O365Interactive

Save this change.

Now, open Thunderbird. On first run, Thunderbird should ask you to set up an existing email address.

Thunderbird "Set Up Your Existing Email Address&quote; menu

Fill in your information.

Click Configure manually.

Thunderbird Account Setup menu with the information filled in. The mouse is about to click "Configure manually"

Scroll down and fill in the information for the davmail bridge.

If you didn't change anything, the incoming server will be:

Again, if you didn't change anything, the outgoing server should be:

the settings as described above

Click Re-test to check these settings and get defaults from the bridge.

Click Done to attempt to log in.

connection security and authentication settings have been auto-filled

Since we're making an unencrypted connection, Thunderbird will throw a warning.

Thunderbird warning about an unencrypted connection

This is fine since we'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.

Check the I understand the risks box and click Confirm.

The "I understand the risks" checkbox has been checked, and the mouse is about to click the Confirm button.

davmail will now open a dialog asking the user to authenticate with Office. Click the link to open it in your browser.

a dialog which asks the user to open the link, authenticate, and paste the resulting authentication code URL back into the dialog

Sign in to your Microsoft account.

sign-in page

My school required Duo authentication as well.

Duo 2FA screen

Duo 2FA with the authentication code entered

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.

Microsoft "Permissions requested" dialog for DavMail

You will be redirected to a blank page. Copy the URL. It contains the OAuth2 code needed for davmail to authenticate.

blank page with an OAuth2 URL

Paste this URL into the davmail window and click OK.

the same davmail dialog as before, but now the authentication code URL has been pasted in

Go back to Thunderbird and click Done again to try to log in.

the Thunderbird Account Setup page again

This time, you should log in successfully.

Account successfully created