Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to connect to UWaterloo's new email system via any mail client

How to connect to UWaterloo's new email system via any mail client

By Raymond Li (Raymo111), December 7th, 2018

Created on July 1st, 2020 (Happy Canada Day!)
Credits to PixlOne for O365Interactive mode and headless Davmail

Step 1: Get Davmail.

  • I'm on Arch Linux, so I installed it from the AUR.

Step 2: Launch and configure Davmail.

  • Use O365Interactive for Protocol, and uncheck Local POP port, Caldav HTTP port, and Local LDAP port. Keep everything else as the default, and hit save.

Step 3: Setup your mail client.

  • I'm using Mailspring, which I believe is the best mail client I can get for free. [Not Sponsored]
  • Use manual config (IMAP/SMTP) to setup the account.
  • Use <your WatIAM username>@uwaterloo.ca as your username and your WatIAM password.
  • Use localhost as the server.
  • Use the ports set in Davmail (1143 for IMAP and 1025 for SMTP by default).
  • Set any authentication to None.
  • The first time you attempt to connect, you'll get a Davmail popup and the UWaterloo adfs page will open. Login with your credentials, and paste the link you reach at the end into the Davmail prompt.

Step 4: Run it as a headless service.

  • Success! Your mail should now work. Davmail basically acts as an interpreter between the O365/Exchange network and IMAP/SMTP. As such, it must be constantly running to receive/send mail. Go ahead and exit Davmail. Copy the properties from your home directory to /etc with:
sudo cp ~/.davmail.properties /etc/davmail/davmail.properties
  • Add a davmail user:
sudo useradd --system davmail
  • Finally, start and enable the service with:
sudo systemctl enable davmail@<your-linux-username> && sudo systemctl start davmail@<your-linux-username>

That's it! Note: Always test and verify via the webapp before relying on any setup!

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

thank you so much for this, i have been trying to find a way to make mailspring work. I am getting a syncing error towards the end of step 3.
I was wonderring if you know how to fix it?

@Raymo111

This comment has been minimized.

Copy link
Owner Author

@Raymo111 Raymo111 commented Feb 22, 2021

@obaranek Can you post a screenshot of your syncing error and a Mailspring log?

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

@Raymo111 where does mailspring store its logs?

@Raymo111

This comment has been minimized.

Copy link
Owner Author

@Raymo111 Raymo111 commented Feb 22, 2021

Hmm... not sure. Do you have davmail running? What's the output of this?

sudo systemctl status davmail@<your-linux-username>
@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

davmail@obaranek.service - DavMail for obaranek
Loaded: loaded (/usr/lib/systemd/system/davmail@.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-02-22 12:14:36 EST; 1h 14min ago
Main PID: 250785 (java)
Tasks: 26 (limit: 18757)
Memory: 39.6M
CGroup: /system.slice/system-davmail.slice/davmail@obaranek.service
└─250785 /bin/java -jar /usr/share/java/davmail/davmail.jar /etc/davmail/obaranek.properties

Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,325 ERROR [main] davmail - Unable to create log file directory
Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,325 ERROR [main] davmail - Unable to set log file path
Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,354 DEBUG [main] davmail.DavGateway - Headless mode, do not create GUI
Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,355 ERROR [main] davmail - Unable to set log file path
Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,355 DEBUG [main] davmail.DavGateway - Start DavMail in server mode
Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,384 INFO [main] davmail - DavMail Gateway 5.5.1-3299 listening on POP port 1110 CALDAV port 1080 LDAP port 1389
Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,385 ERROR [main] davmail - Unable to bind server socket for SMTP on port 1025: port not allowed or in use by another process
Feb 22 12:14:36 arch davmail[250785]: Unable to bind server socket for IMAP on port 1143: port not allowed or in use by another process
Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,436 DEBUG [CheckRelease] davmail.http.HttpClientAdapter - GET http://davmail.sourceforge.net/version.txt
Feb 22 12:14:36 arch davmail[250785]: 2021-02-22 12:14:36,686 DEBUG [CheckRelease] davmail.DavGateway - DavMail released version: 5.5.1-3299

@Raymo111

This comment has been minimized.

Copy link
Owner Author

@Raymo111 Raymo111 commented Feb 22, 2021

It seems that davmail doesn't have the perms to really do anything (i.e. create log file or use your ports). Did you follow all the steps I listed?

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

i did, these are my davmail settings
image

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

this is the mailspring log

image

@Raymo111

This comment has been minimized.

Copy link
Owner Author

@Raymo111 Raymo111 commented Feb 22, 2021

What do you get when you run groups davmail?

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

i get "davmail"

@Raymo111

This comment has been minimized.

Copy link
Owner Author

@Raymo111 Raymo111 commented Feb 22, 2021

Try rebooting your system for davmail user perms to propagate, and then run the status command again after reboot to see if the same error persists.

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

after rebooting, this is my ouput

davmail@obaranek.service - DavMail for obaranek
Loaded: loaded (/usr/lib/systemd/system/davmail@.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-02-22 13:51:11 EST; 56s ago
Main PID: 2291 (java)
Tasks: 28 (limit: 18757)
Memory: 66.5M
CGroup: /system.slice/system-davmail.slice/davmail@obaranek.service
└─2291 /bin/java -jar /usr/share/java/davmail/davmail.jar /etc/davmail/obaranek.properties

Feb 22 13:51:11 arch davmail[2291]: 2021-02-22 13:51:11,993 ERROR [main] davmail - Unable to create log file directory
Feb 22 13:51:11 arch davmail[2291]: 2021-02-22 13:51:11,993 ERROR [main] davmail - Unable to set log file path
Feb 22 13:51:11 arch davmail[2291]: 2021-02-22 13:51:11,993 ERROR [main] davmail - Unable to create log file directory
Feb 22 13:51:11 arch davmail[2291]: 2021-02-22 13:51:11,993 ERROR [main] davmail - Unable to set log file path
Feb 22 13:51:12 arch davmail[2291]: 2021-02-22 13:51:12,061 DEBUG [main] davmail.DavGateway - Headless mode, do not create GUI
Feb 22 13:51:12 arch davmail[2291]: 2021-02-22 13:51:12,063 ERROR [main] davmail - Unable to set log file path
Feb 22 13:51:12 arch davmail[2291]: 2021-02-22 13:51:12,063 DEBUG [main] davmail.DavGateway - Start DavMail in server mode
Feb 22 13:51:12 arch davmail[2291]: 2021-02-22 13:51:12,123 INFO [main] davmail - DavMail Gateway 5.5.1-3299 listening on SMTP port 1025 POP port 1110 IMAP port 1143 CALDAV port 1080 LDAP port 1389
Feb 22 13:51:12 arch davmail[2291]: 2021-02-22 13:51:12,232 DEBUG [CheckRelease] davmail.http.HttpClientAdapter - GET http://davmail.sourceforge.net/version.txt
Feb 22 13:51:12 arch davmail[2291]: 2021-02-22 13:51:12,256 DEBUG [CheckRelease] davmail - Unable to get released version

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 22, 2021

this is my output after rebooting
image

mailspring doesn't seem to be syncing but there is no error

this it what i see in davmail

image

@Raymo111

This comment has been minimized.

Copy link
Owner Author

@Raymo111 Raymo111 commented Feb 22, 2021

Hmm... not sure. Seems like davmail is disconnecting after a successful connection, but I have no idea why. Sorry mate.

@obaranek

This comment has been minimized.

Copy link

@obaranek obaranek commented Feb 23, 2021

no worries, thanks for your help!

@Raymo111

This comment has been minimized.

Copy link
Owner Author

@Raymo111 Raymo111 commented Feb 23, 2021

❤️
Huh seems like Gist doesn't have reactions.

@martellato

This comment has been minimized.

Copy link

@martellato martellato commented Apr 1, 2021

Hey, thanks a bunch for this! I got it working on Thunderbird, but I ended up using the EWS protocol instead of the O365Interactive. For some reason, it failed to authenticate that way. The window would pop up but go nowhere after the certificate warning. Maybe that will help @obaranek too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment