Connecting to Office 365 via Exchange
My University emails are run through Office365 and I was trying to set up access to them via Exchange Web Services (EWS) in Evolution. I managed it before, but I've since reinstalled my computer. Unfortunately, I kept getting 404 errors every time I tried to set it up because outlook.office365.com couldn't be found and Evolution EWS (helpfully?) guesses at other possible paths if the one you specify fails - it was ultimately trying to connect to my University's domain, which then issued a 404.
Set up Evolution
First, you'll need to install
evolution-ews, and then launch Evolution. When you first run Evolution, it'll ask you to set up an account, but if you've already got one set up, you can just go to Edit -> Preferences -> Mail Accounts -> Add.
Hit "Next" and enter your name, email address and anything else relevant. I'd suggest unticking "Look up mail server details" because it won't help you here, but it doesn't matter if it does run.
Set the server type to "Exchange Web Services", then enter your username in the relevant field (take care to ensure that it's in the correct form - mine requires the domain, yours might not). Now, enter https://outlook.office365.com/EWS/Exchange.asmx as the Host URL and click "Fetch URL". Enter your password in the prompt and wait a little while. The OAB URL should automatically be filled if you're successful and you can finish the configuration wizard, but if you get an error at the bottom that says either "404 Not Found" or "Name or service not known" then you've encountered the problem I had!
Unfortunately, outlook.office365.com requires that the DNS (Domain Name Server) supports IPv6, which has not yet fully been adopted and so the servers used by some ISPs can cause issues.
You can test this behaviour by running
ping outlook.office365.com. If you get a response, then your DNS supports IPv6, but if you get a response that says that the service or name is not known, then you can try
ping -4 outlook.office365.com which forces the use of IPv4. If the latter command works, then outlook.office365.com is working correctly and the problem is on your end (or arguably in the middle).
There are actually a few of solutions possible here:
- Change your DNS to one that supports IPv6.
- Use an IPv4 address instead of the URL (skip the DNS).
- Add outlook.office365.com to your
/etc/hostsfile with an IPv4 address.
1. Change your DNS
This is the most general solution and should help you to avoid issues with other services in the future. Simply go into your router configuration, find the entry for DNS and specify 184.108.40.206 and 220.127.116.11 (these are Google's DNS servers).
2. Use an IPv4 address
When you run
ping -4 outlook.office365.com, it should display an IP address (something like 18.104.22.168). You can actually use this address in Evolution by setting your Host URL to "https://22.214.171.124/EWS/Exchange.asmx" and then clicking "Fetch URL". Please note though, that when you fetch the URL, it will change both the Host and OAB URLs to use domains rather than IP addresses, and so you will need to edit both entries (replace "outlook.office365.com" with the relevant IPv4 address).
3. Add outlook.office365.com to your /etc/hosts
For entries in your
/etc/hosts file, no DNS lookup needs to be made - this file provides the lookup that the DNS server otherwise would. Simply add a line at the bottom that says
126.96.36.199 outlook.office365.com, with the IP address replaced by whatever IP address
ping -4 outlook.office365.com gives you.