I've become increasingly frustrated with the limitations of Thunderbird, and finally started taking the steps to migrate to a more powerful email client, mutt. This had been daunting for some time as Thunderbird handles a lot of the behind-the-scenes work for you — retrieving email (it's a mail delivery agent, MDA), sending email (and a mail transfer agent, MTA), and other things besides in addition to being a mail user agent (MUA). mutt, in contrast, is more or less a straight MUA, so you have to figure out how to fill those roles.

Fortunately, there's great software and lots of guides out there to help with this. Unfortunately, my work's mailserver is Micro$oft Exchange, which uses Exchange ActiveSync (EAS) with IMAP and SMTP disabled. I wrote this up to hopefully help other users in similar situations configure their systems successfully.


I use Ubuntu GNU/Linux; while the specifics and installation might be different on other platforms, I think the general framework will hold. My kernel and release info:

$ uname -rio
  4.4.0-128-generic x86_64 GNU/Linux
$ lsb_release -dc
  Description:	Ubuntu 16.04.4 LTS
  Codename:	xenial

Here's the way my system is now set up:

Mail system flowchart

I'm very grateful that davmail exists. It's a simple Java program that provides an IMAP/SMTP frontend locally and then interacts with an EAS server. I'm not aware of a good alternative — if you are, please reach out!

mbsync and msmtp are wonderful, lightweight IMAP and SMTP clients, respectively. mbsync is sometimes referred to as isync, its historical name. The installation package is still isync on many platforms (including Ubuntu), but the executable is mbsync. You can certainly use more classic MTAs like sendmail, but for a single-user system my impression is that it's unnecessarily complex.


On Ubuntu, all are available on the repos as of 18.04 LTS (bionic beaver). For 16.04 LTS, mbsync and msmtp are available, however, some of the features used in my configuration of mbsync are only available in newer versions, and so I compiled from source. davmail has a .deb package which you can easily install with dpkg on its website.

If you're on Ubuntu 18.04 LTS, you should be able to simply

$ sudo apt install davmail isync msmtp mutt

without issue, but as upgrades won't be released until late July 2018, I haven't tried this yet.

Incoming mail (EAS/IMAP) — mbsync + davmail

davmail installation is blessedly uncomplicated. By default, it accepts IMAP and SMTP locally on ports 1143 and 1025 respectively. You have to set the URL for your Outlook Web Access (the way you access your email in a browser, which should end with /owa/ — for example, https://mail.yoyodyne.com/owa/), and the destination for davmail's logfiles. All of this information is stored in .davmail.properties and can be easily re-edited there.

To have davmail start on boot without the tray icon, you can add

/usr/bin/davmail -notray

to your startup applications.

mbsync has a more complex setup that I don't begin to fully understand. However, once configured, it runs easily, and you can easily have multiple accounts. 1 A two-account .mbsyncrc using davmail looks like this:

IMAPAccount home
Host mail.xyzzy.org
Port NNN
User plugh
PassCmd "gpg2 -q --for-your-eyes-only --no-tty --batch -d ~/.mail-home.gpg"

IMAPStore home-remote
Account home

MaildirStore home-local
Subfolders Verbatim
Path ~/mail/home/
Inbox ~/mail/home/Inbox

Channel home
Master :home-remote:
Slave :home-local:
Patterns * !Archives !Lists

Create Both
Expunge Both
SyncState *


IMAPAccount work
Host localhost
Port 1143
User thud
PassCmd "gpg2 -q --for-your-eyes-only --no-tty --batch -d ~/.mail-work.gpg"
SSLType None
AuthMechs LOGIN

IMAPStore work-remote
Account work

MaildirStore work-local
Subfolders Verbatim
Path ~/mail/work/
Inbox ~/mail/work/Inbox

Channel work
Master :work-remote:
Slave :work-local:
Patterns * !Archives

Create Both
Expunge Both
SyncState *

where mail.xyzzy.org, NNN, and thud represent your mailserver address, port number, and Exchange username, respectively.

A few comments:

And you're set! Now, to sync, you can run mbsync home, mbsync work, or mbsync -a for all mailboxes. I have it set to sync my mail every two minutes with the following entries in my crontab:

*/2 * * * * mbsync -a 2>>$HOME/mail/logs/mbsync.log 
@weekly  cd $HOME/mail/logs && echo "$(tail -1000 mbsync.log)" > mbsync.log

You can omit the logging of stderr and the second entry (which just periodically trims the log) if you don't want any logging.

For sending mail, see part 2!

For configuring mutt for multiple accounts, see part 3!


  1. Packaged versions of mbsync (as of June 2018, v1.3.0) include a bug which leads to duplicate messages when using davmail. This is not currently fully patched, but is easy to solve if you build from source. Obtain it and its dependencies as follows:

    $ git clone https://git.code.sf.net/p/isync/isync
    $ sudo apt install libssl-dev

    The offending code is in drv_imap.c. As of v1.3.1, this is partially patched, but on line 2925 (which reads "UID FETCH *:* (UID) );" there's another error. To fix this, replace '*:*' with '*' on that line, which should then read "UID FETCH * (UID) );". You can then build with

    $ ./autogen.sh
    $ ./configure
    $ make
    $ sudo make install

    as described in the README, which will put the resulting binary in /usr/bin/local. Hopefully this will be fully patched and packaged soon! Note that if you use cron to call mbsync that /usr/local/bin may not be in its path, or that it may come after any version that was installed by your package manager, meaning that you may need to specify /usr/local/bin/mbsync or modify cron's $PATH