This is on an Xperia X Compact with Android 7.0. I get the error message "Can't establish server connection"1 when I want to sync my email while connected to my home WiFi.
- Other IMAP accounts sync without a problem
- Using the stock email app for Gmail worked fine on Marshmallow
- Using Gmail in the stock email app works when I'm on mobile data (!)
- Using other email apps (e.g. Gmail, K-9, BlueMail) to connect to Gmail while on WiFi works as well
- I have been able to add the Gmail account and initially synchronize my emails on the same WiFi network without any problems
- There is no error message under Accounts -> Google -> Synchronize Gmail
Things I have tried:
- Deactivate and reactivate mail app
- Clear data of the mail app
- Remove and re-add Google account
- Complete factory reset via Xperia Companion
- Disable two-factor auth
- Add Gmail manually as an IMAP account in the mail app
- Allowed less secure apps in Gmail settings
- Check Gmail's IMAP settings on Desktop (it's enabled)
I haven't had the opportunity to test it on a different network than my home WiFi yet, but to me this looks more like a software problem since all other email clients, as well as the initial setup worked fine? There are of course a number of obvious workarounds (use Gmail / other email client), but I would prefer the stock email app to work as it fits my needs best.
1 All error messages and descriptions of settings have been translated from German. Please edit if you know the exact English translations so other people with the same problem can find this question more easily.