mscdex / node-imap

An IMAP client module for node.js.
MIT License
2.16k stars 380 forks source link

Office365 - A3 BAD User is authenticated but not connected #689

Open bcsridhar opened 6 years ago

bcsridhar commented 6 years ago

When I try to connect to my office365 account I get the below error, "A3 BAD User is authenticated but not connected" The same code works for sometimes also I have checked the password by logging into webmail. Please help,

Debug Log:- <= 'A1 OK LOGIN completed.' => 'A2 CAPABILITY' <= '* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CLIENTACCESSRULES CLIENTNETWORKPRESENCELOCATION BACKENDAUTHENTICATE CHILDREN IDLE NAMESPACE LITERAL+' <= 'A2 OK CAPABILITY completed.' => 'A3 NAMESPACE' <= 'A3 BAD User is authenticated but not connected.

mscdex commented 6 years ago

A brief google search reveals it could be at least one of three possibilities:

1. It is a Microsoft's mechanism to shut down chatty clients. The solution would be to login to this account less frequently. 2. It is due to a bug in the IMAP implementation. If the client presents a valid user name but an invalid password, the server accepts the login, but subsequent commands fail with the aforementioned error message. 3. It is a shared mailbox and you are using incorrect login scheme. Use Username@DomainName\SharedMailboxAlias for O365

If none of those help, I'm not sure what to suggest, you will have to contact either whoever administers your account or Microsoft because there is something misbehaving on the server side.

bcsridhar commented 6 years ago
  1. I can confirm that the password is correct because i am able to login to this account via webmail.
  2. Also its not a shared mailbox.
  3. But since I have configured a cron job which runs every 5 mins the first point about chatty clients could be the problem, Since the nature of application is such that I cant avoid connecting this account every 5 or 10 mins to sync the emails.

Is there any workaround that i can implement ?

mscdex commented 6 years ago

I have no personal experience with Microsoft IMAP servers, so I do not have anything to suggest other than look around on google for other possible solutions and/or contact Microsoft about it.

bcsridhar commented 6 years ago

Thanks for that, what if I keep the connection alive (keepalive : true) and reuse the connection instead of login and login out multiple times will that considered a chatty client.

mscdex commented 6 years ago

I really don't know, it may be worth a try though.

MichaelKreutz commented 6 years ago

@bcsridhar Hi. Did you find a solution or workaround to this problem. I seem to face a similar situation where I get this error after doing some operations on the mail box.

Roledenez commented 6 years ago

I am facing the same issue, is there any workaround found?

what I am trying to is, every 30 seconds I am checking my office o365 mail account that is there any mail arrived.

it works for few successful attempts, but suddenly this error appears

`events.js:183 throw er; // Unhandled 'error' event ^

Error: User is authenticated but not connected. at Connection._resTagged (I:\Projects\QFRM\KEDBNodeElasticSearch\node_modules\imap\lib\Connection.js:1502:11) at Parser. (I:\Projects\QFRM\KEDBNodeElasticSearch\node_modules\imap\lib\Connection.js:194:10) at emitOne (events.js:116:13) at Parser.emit (events.js:211:7) at Parser._resTagged (I:\Projects\QFRM\KEDBNodeElasticSearch\node_modules\imap\lib\Parser.js:175:10) at Parser._parse (I:\Projects\QFRM\KEDBNodeElasticSearch\node_modules\imap\lib\Parser.js:139:16) at Parser._tryread (I:\Projects\QFRM\KEDBNodeElasticSearch\node_modules\imap\lib\Parser.js:82:15) at TLSSocket.Parser._cbReadable (I:\Projects\QFRM\KEDBNodeElasticSearch\node_modules\imap\lib\Parser.js:53:12) at emitNone (events.js:106:13) at TLSSocket.emit (events.js:208:7) [nodemon] app crashed - waiting for file changes before starting...`

Rebaiahmed commented 6 years ago

@Roledenez me too i have the same issue , please can you help me to implement it

ayushnawani commented 4 years ago

@Roledenez @Rebaiahmed @bcsridhar facing the same issue with outlook. Did you guys get any solution?

purijatin commented 3 years ago

Any solution to this problem?

grtaylor806 commented 3 years ago

This is the error you'll get when IMAP is disabled at the user level. Set-CasMailbox -ImapEnabled $True/$False.

It might also be the case if Security Defaults are enabled, meaning Basic Auth is disabled. New tenants created these days have Security Defaults enabled.

purijatin commented 3 years ago

I was getting this error when more than two connections were being made from the same machine. It was rejecting the third connection. Restricting it to one connection solved the problem for me.