One of the nice things about working for Canonical these past many years was having an entirely Linux-based infrastructure. For the most part I never needed to worry about the existance of Windows.
Yet, having now joined a company, that – like most of the modern world – is fundamentally Microsoft infrastructured, I find myself needing to interface with Exchange to get and send my email.
At first I took the easy route of using Outlook webmail in firefox. This wasn’t total frustration, I actually kinda liked the conversation grouping feature. But inevitably the frustrations eventually hit a breaking point!
I assumed setting up mutt with Exchange would be a well trod path on the Internet and I could just paint-by-numbers my way through. No such luck. So, in hopes of saving others some work of piecing things together from man pages, random forum posts, and plain trial and error, here’s my guide for getting this all set up.
Certain Linux-based mail clients like Thunderbird and Evolution are able to speak directly with Exchange using EWS. However, there are many other Linux email and calendaring clients available that you may want to use, but that don’t support Exchange EWS. For instance, you may wish to use a console-based mail client such as mutt.
Fortunately, you can set up DavMail as an intermediary gateway. DavMail interfaces with the Exchange server, presenting it as a standards-compliant POP/IMAP/SMTP/Caldav/Carddav/LDAP service. In other words, you use IMAP or POP to browse or retrieve emails, SMTP to send email, LDAP to look up addresses, Caldav for calendaring, and Carddav for personal contacts.
Setting up the DavMail server
The DavMail package can be downloaded from http://davmail.sourceforge.net/download.html. At the time of this writing it appears to not exist in the Ubuntu archive, however a .deb file suitable for Debian and Ubuntu is available from the above link. For other Linux distributions you’ll need to use the standard tarball package and manually install Java.
# Install on Ubuntu
sudo apt-get install libswt-gtk-3-java # Or other java as desired
sudo dpkg -i davmail_4.3.3-2146-1_all.deb
You can then launch DavMail via the Applications/Internet menu.
DavMail does not store any credentials, it merely needs to know the name and path of the Exchange server to use. The first time you launch DavMail, a configuration dialog will appear. Only one parameter needs changed:
URL OWA (Exchange): https://webmail.your.company.com/EWS/Exchange.asmx
The rest of the settings can be left at defaults. See the DavMail Tutorial for info about the rest of the settings or if you run into problems. Note that logging information is written to ~/davmail.log.
Finally, set up DavMail to start up on session login. For example:
echo "davmail &" >> ~/.gnomerc
I’d never heard of DavMail before, but it’s been quite solid so far.
Setting up msmtp SMTP client
Sendmail is the de facto standard for SMTP, but is a bit overkill if you’re just setting up a single user local email environment. msmtp is simpler
to configure and adequate for single user email needs.
sudo apt-get install msmtp
touch ~/.msmtprc ~/.msmtp.log
chmod 600 ~/.msmtprc ~/.msmtp.log
Since the IMAP server is on localhost, the msmtp configuration is quite basic:
Here, PASSWORD is your own password, DOMAIN is going to be something specific to your company, and for AUTH it’ll depend on how you want to have things set up. See msmtp authentication for options.
Setting up mutt for email
If you’ve used mutt before, you’ll already be familiar with its myriad configuration options. If you haven’t, then this section isn’t for you!
So, skipping over installation and basic mutt configuration, here’s how to configure mutt to use IMAP. This keeps the emails and folders on the remote server and uses the local DavMail service for sending and receiving emails.
set realname='Firstname Lastname'
set imap_keepalive=900 # Set lower if connection times out
my_hdr From: "Firstname Lastname"
Setting up git
You can direct git to send patches through SMTP via the DavMail server.
name = Firstname Lastname
email = email@example.com
smtpserver = localhost
supresscc = self
from = Firstname Lastname
smtppass = PASSWORD
smtpserverport = 1025
smtpuser = f.lastname
confirm = auto
chainreplyto = true