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
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:
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
msmtp are wonderful, lightweight IMAP and SMTP clients,
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
sendmail, but for a single-user system my impression is that it's
On Ubuntu, all are available on the repos as of 18.04 LTS (bionic beaver). For
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
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,
and the destination for
davmail's logfiles. All of this information is
.davmail.properties and can be easily re-edited there.
davmail start on boot without the tray icon, you can add
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
davmail looks like
IMAPAccount home Host mail.xyzzy.org Port NNN User plugh PassCmd "gpg2 -q --for-your-eyes-only --no-tty --batch -d ~/.mail-home.gpg" SSLType STARTTLS 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 *
thud represent your mailserver address,
port number, and Exchange username, respectively.
A few comments:
- You can call your accounts whatever you want, I just chose
workas examples. You just have to be consistent throughout.
You can put any command that generates your password in
PassCmd(for example, accessing the system keyring). To generate an encrypted password file with GPG, one easy way is
$ echo 'password' | gpg2 -r firstname.lastname@example.org -e -o output.gpg
On most terminals, prepending a space prevents this from being stored in your history, but it's worth checking and deleting the entry if possible so your password isn't stored anywhere in plaintext.
Subfolders Verbatimcreates an identical folder tree for your local Maildir as what you have on your mail server. There are lots of other options!
- You can of course choose different locations for
Patterns *will match all of your remote folders and treat them as Maildirs, meaning that locally those files will have
tmpsubdirectories. You can exclude directories by prefixing them with
!. Here, I have subdirectories of
Listswhich are each Maildirs, but I want to exclude those so they aren't treated as Maildirs. The subfolders are still synced without issues.
- For the work account, the
Portfields are the defaults for
- If you have to log in with a domain, you have to use two backslashes (e.g.
DOMAIN\\thud) to escape the backslash.
- While you're testing things, you may want to comment out
Expunge Both. This actually removes deleted files rather than simply marking them as being deleted, so it's more permanent.
- For the
LOGINbut not other forms without more configuration. I don't think there's much issue with this on a small system as all the data transfer is local, but there may be ways to encrypt it locally as well if you like.
And you're set! Now, to sync, you can run
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
*/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!
mutt for multiple accounts, see part
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
/usr/local/binmay 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