Outlook Oauth2 - Cannot connect to server. (Command: NAMESPACE; response: #4# [BAD, User is authenticated but not connected.])

According to a quick Google search (result on Stack overflow), this means that you used the correct username/password, but you have not enabled IMAP permissions in your account settings.

No that is not it. I checked the settings and also it is working fine from Thunderbird on my laptop

Are you absolutely sure? K-9 does not register as Thunderbird Mobile, yet. Thus, from Office365’s perspective, this is a different app with a different trust domain and different scope. The IMAP permission set for Thunderbird thus may not apply for K-9.

See Authenticate an IMAP, POP or SMTP connection using OAuth | Microsoft Learn and related articles for app registration therein.

edit/ In some very strict corporate environments your admin must validate and enable apps one by one. Just ask them, if they can enable K-9 permissions for you. However, due to policies they might force you to use the Outlook mobile app.

1 Like

I too have the same problem since yesterday.

My Tenant is set so that users can enable apps and all worked “OK” for K9 when I switched to OAUTH 2.0 a while back, and all was working OK until yesterday.

I am no expert, but the way I read articles mentioned it needs to be the owner of the APP to perform the necessary actions in Azure AD, not the “end-user” of the APP. I am the “admin” of my O365 Tenant but do not have (or understand) the Azure AD “stuff” and I’m surprised if the suggestion is that all users of K9 have to do this,

I use another APP using IMAP to access my email via outlook.office365.com and it too “broke” yesterday, but in that one it is possible to “click” on the password for the account and select “Update authorization” which “does the trick” and that APP is synchronising OK again without any admin changes in my Tenant. Unfortunately, I can’t find of redoing or updating the OAUTH 2.0 authorization in k9.

I have the same issue since few days – yet, also with Thunderbird. (Before that, both were smoothly working with oauth2.)
On Thunderbird, the connection can be established by disabling IPv6, see here:

Is there such a (hidden) option for K9?
Thanks for you response in advance!

1 Like

Not necessarily for K-9, but you can set a private DNS that only returns IPv4.

Android Settings → Network and Internet → Private DNS

Examples (make sure to use the IPv4 address, not the hostname, otherwise they will also resolve AAAA records for IPv6):

  • (Freifunk München)
  • (CensurfriDNS Denmark)
  • (BlahDNS)

Thank you for idea.
Unfortunately, my android does not want to eat any of these addresses (the save button stays gray).
That might be due to the (local) VPN (for Blokada with its encrypted DNS option) that I’m using.

On the other side, I got the idea to switch off the wifi and connect using mobile data only. Indeed, then I get a connection established.

As cross-reference is a bug in the Mozila Bug tracker for Thunderbird, they seem to both share the same errors, while FairEmail doesn’t. I’m not yet certain if FairEmail would share the same errors if it would you IPv6 (which it seem to do right now): 1807918 - Microsoft 365 IMAP using OAuth2 suddenly (from 20221227+ on) fails with 'User is authenticated but not connected" for a couple of users and installs. But MTP send with same oauth2 token is working OK

Same issue with K-9, started last night. Desktop Thunderbird is OK as is logging into outlook.office.com.

I don’t think this is a bug in K-9 Mail. It’s Outlook servers doing weird things. Please contact your email provider and ask them to fix the issue.

1 Like

That’s what my current impression is to after reading some comments on Microsoft forums[1] and when comparing other IMAP clients against outlook.office.com. So far no known issues are visible in Microsoft Admin Center (at least in the Microsoft tenant where I have admin rights that is in western europe).

[1] Thunderbird IMAP responded: User is authenticated but not connected

1 Like

I’m finding this very puzzling:

  • My Tenant has “User Consent” set On.
  • I have “revoked” and “removed” K9 from at myapps.microsoft.com (over 12 hours go) I think! K-9 is no longer listed in “MyApps” Apps list.
  • but (still) in “check incoming server (with Oauth 2.0)” in K9 it appears to complete without the “NAMESPACE” error!
  • K9 does NOT synchronise when connected by WiFi BUT does when WiFi is turned off!
  • As a Tenant Admin I have tried adding K-9 back into “MyApps” - it’s in the “list” of possible Apps but doesn’t “stick” on saving.
  • My Router has IP4 set for DNS (so unless there is a bug …)

In my Googling about Oauth2 today I think I spotted a recent article (but can’t find it again) suggesting that App Developers needed to reauthorize their Apps via a new(?) AzureID method (is this why my “adding” doesn’t “stick”?) and / or users need to “reauthorise” the App to access their Microsoft 365 data (i.e. the process where setting up the incoming server you are taken to a Microsoft login page and then you have confirm the app can have access to your M365 data). If it is the latter I can’t find a way of getting K9 to do that and I don’t really want to try totally uninstalling to see if that works.

My final puzzle is that FairEmail works OK after my having to “reauthorise” it in the last couple of days as per described above from within my FairEmail email account settings - no changes needed within my Tenant settings for FairEmail needed.


EDIT - I should have added that K9 syncs OK with none outlook365 addresses over WiFi so it seems, in my case, K9 has a problem with M365 email over WiFi BUT other apps (FairEmail) don’t.

Has anyone come up with a solution yet? Has MS changed their Oauth2 that’s causing this issue with K-9? How can I set K-9 to request authentication again, and login to MS365, without deleting the account? All is set properly on my MS365 Admin/Tenant. I prefer to continue using K-9 and not switch Android EMail client software (ie FairMail, Aqua, Blue, Oulook).

FWIW, I’ve had no issues with my Thunderbird desktop app.

I switched to the Android Gmail client for now and it’s working.

I am having the same problem with Thunderbird. Using outlook web client (yuk) for now on Linux.

Really missing K9

Anyone have an answer? I don’t want to have to leave K9 but need something working by tomorrow.

Have you tried removing the account from K-9 Mail, then adding it again?

Yes I have. Tried POP3 and IMAP but same error.

1 Like

Hopefully, MS will fix it soon (or at least shed some light on the issue). Unfortunately, there are only workarounds so far. Did switching to IPv4 not work for you? For example with mobile network connection (instead of wifi) or by using private DNS as suggested by tchara:

1 Like

Unfortunately it did not work for me.

This is probably related to our issue - Redirecting