Add Outlook and Gmail to Nextcloud Mail

Notes

I use several email accounts and wanted one place to read and send mail from both my phone and computer. I ended up using the Mail app in my self-hosted Nextcloud instance. Nextcloud Mail is an email client, not a mail provider: you still need working accounts with IMAP/SMTP or OAuth support.

I spent a few hours getting the accounts connected, so here are the issues I ran into and the current setup notes. The authentication steps have changed since I first wrote this post.

“IMAP server is not reachable”

I saw this error while adding a mail.ru account. I had enabled a proxy to reach Gmail; turning it off and connecting directly fixed the problem for me. That does not prove that the proxy address was blocked. For a similar error, check DNS resolution, outbound firewall rules, proxy or VPN routing, and the provider’s IMAP hostname, port, and TLS settings.

Add an Outlook or Microsoft account

Nextcloud Mail supports OAuth for hosted Microsoft Outlook accounts. For Exchange Online, Microsoft has disabled Basic authentication for IMAP and other protocols. An app password cannot work around that restriction, so the Nextcloud administrator needs to configure the Microsoft OAuth integration first.

Configure Microsoft OAuth

In Nextcloud’s administration settings, open Groupware and find the Microsoft OAuth settings. Copy the redirect URI shown there. In the Microsoft Entra admin center (Azure portal), register an application that allows organizational and personal Microsoft accounts, and add that URI as a Web redirect URI. Create a client secret, then enter the application’s client ID and secret in Nextcloud’s Groupware settings. For the standard personal and organizational account setup, leave the tenant ID as common.

After saving the settings, open Nextcloud Mail and add a Microsoft or Outlook account. Enter the email address; the password field is discarded and Microsoft opens a consent window for sign-in. Complete that flow to connect the account. A work or school tenant may also require its administrator to grant consent.

Microsoft and Nextcloud can move or rename settings, so follow the current Nextcloud XOAUTH2 setup guide. Microsoft explains the Exchange Online change in its Basic authentication deprecation notice.

Add Gmail

The recommended route is Google OAuth. A Nextcloud administrator must create OAuth credentials in Google Cloud, then enter the client ID and secret under Administration settings → Groupware → Gmail integration. Once saved, users can add Gmail through the Google authorization flow. See the Nextcloud Google OAuth instructions.

If your Nextcloud instance has not configured Google OAuth, an app password may work as a fallback. Google requires 2-Step Verification to create one and says app passwords are not recommended when an app offers Sign in with Google. Some work, school, or Advanced Protection accounts cannot use app passwords. See Google’s app password help.

For personal Google accounts, Gmail IMAP has been on by default since January 2025, and the old Enable IMAP toggle is gone. Google Workspace administrators may still control access for organization accounts. See Add Gmail to another email client.

A final note

Managing a pile of email accounts gets annoying fast. If you found this post while trying to connect one more address, take it from me: creating a separate inbox for every little thing means more account maintenance later.