How to get email from exchange server without Outlook
Table of Contents
This article has three parts.
First part explains how to set up gateway davmail.
Second part uses thunderbird to fetch mails from exchange server.
Third part uses Emacs and Gnus to get mails. Non-technical guy can skip this part.
1 davmail as email gateway
What's davmail, quoted from its site:
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, on 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 it has some GUI front end, it's dependent on SWT. So I give the instruction on how to install SWT in ubuntu. If you don't use ubuntu, then you may be already geek 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 cannot detect your Exchange server automatically!
If Exchange server uses un-conventional EWS URL which cannot be detected by davmail, 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".
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.
3 Emacs Gnus
Gnus cannot access IMAP service of davmail. There is some bug.
So we have to turn to POP3. Check documentation at EmacsWiki.
The key point is DO NOT delete emails 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 set up on 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.
Now the bad news: Our IT administrator blocks davmail access because it relay too many requests from Gnus in short time! My solution is to use another IMAP client thunderbird to clean up the INBOX folder before start Gnus.
Another tip is whenever open a folder in Gnus, press "C-u ENTER" instead of "ENTER" key. "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.