How to get email from exchange server without Outlook
This article has three parts.
First part explains setup of mail gateway DavMail for Exchange server.
Second part uses thunderbird to fetch mails from Davmail.
Third part uses Emacs and Gnus to replace thunderbrid. It's optional.
DavMail as mail gateway
Ever wanted to get rid of Outlook ? DavMail is a POP/IMAP/SMTP/Caldav/Carddav/LDAP exchange gateway allowing users to use any mail/calendar client (e.g. Thunderbird with Lightning or Apple iCal) with an Exchange server.
Download the installer at Debian/Ubuntu/Mint:
sudo apt-get install libswt-gtk-3-jni libswt-gtk-3-java libswt-cairo-gtk-3-jni # ubuntu/debian only; for other distribution, just download src package sudo dpkg -i davmail_4.5.1-2303-1_all.deb
Installation is easy. DavMail by itself is a portable java application. Since its GUI is dependent on SWT. So I give the instruction on how to install SWT in ubuntu. If you don't use ubuntu, then you are already technically good enough to know how to install SWT.
Now start DavMail.
Please input the web Outlook url like "https://webmail.mycompany.com.au/owa/" in its GUI.
By default all the services are NOT encrypted. It makes sense because email client and gateway are at the same computer.
Write down the port numbers. In my case, I need port number of IMAP/POP3/SMTP.
That's all you need to do unless DavMail can't detect your Exchange server automatically!
If Exchange server uses un-conventional EWS URL, you need find the URL manually with EWSEditor.
For example, my EWS URL is
https://my-company.local/EWS/Exchange.asmx. In DavMail, input that URL in "Main -> OWA (Exchange) URL" and force the "Exchange Protocol" into "EWS".
BTW, https://outlook.office365.com/ EWS URL is
Create a new account, and manually configure the server. The server name is "127.0.0.1", the port number is already on your paper. The minimum setup needs IMAP port to receive mail and SMTP port to send email.
You don't need care about ssl stuff, let thunderbird handle it. But if you get the error message like "BAD command authentication required" in davmail's log, modify setup in "Account Settings -> Server Settings -> Security Settings -> Connection Settings". Select "None".
The only issue is the "Username". You can log in Outlook Web UI, click "Options -> Change Password". The user name is displayed above the first input box. Please note the full user name may include the work domain.
Gnus cannot access IMAP service of DavMail. There is some bug.
So we have to turn to POP3. Check documentation at EmacsWiki.
If you use POP3, don NOT delete mails on server. You must set the variable "pop3-leave-mail-on-server" to true!
Insert below code into your ~/.emacs:
;; gnus+davmail bug, so I have to use pop3 for DavMail ;; http://permalink.gmane.org/gmane.emacs.gnus.general/83301 ;; but delete all the mails on server is scary (setq pop3-leave-mail-on-server t) (add-to-list 'gnus-secondary-select-methods '(nnml "mycompany")) (setq mail-sources '((pop :server "127.0.0.1" ;; DavMail is running at localhost :port 1110 :user "username" :password "password" :stream network))) ;; by default, DavMail don't encrypt mail
Since I've got many mails in INBOX folder, POP3 could take some time to get them. In worst cases, IT administrator may block DavMail access because it relay too many requests from Gnus! The solution is to use another IMAP client like thunderbird to clean up the INBOX folder before start Gnus.
Another tip is when opening a folder in Gnus, press
C-u ENTER instead of
C-u here means display all the read and unread mails. It's awkward when product manager ask you open an important mail but that mail is invisible because it's marked READ. Check my article Practical guide to use Gnus with Gmail for more tips.