UvA-FNWI / M365-IMAP

MIT License
70 stars 17 forks source link

User is authenticated but not connected #8

Closed Zambito1 closed 2 years ago

Zambito1 commented 2 years ago

Firstly, thanks for making this. After following the steps in the README and running offlineimap, I get this error:

OfflineIMAP 7.3.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.06, Python v3.10.4, OpenSSL 1.1.1n  FIPS 15 Mar 2022
Account sync outlook:
 *** Processing account outlook
 Establishing connection to outlook.office365.com:993 (outlook-Remote)
 ERROR: While attempting to sync account 'outlook'
  LIST command error: BAD [b'User is authenticated but not connected.']. Data: b'CEDD6 LIST "" ""\r\n'
 *** Finished account 'outlook' in 0:04
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'outlook'
  LIST command error: BAD [b'User is authenticated but not connected.']. Data: b'CEDD6 LIST "" ""\r\n'

Traceback:
  File "/usr/lib/python3.10/site-packages/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File "/usr/lib/python3.10/site-packages/offlineimap/accounts.py", line 374, in __sync
    remoterepos.getfolders()
  File "/usr/lib/python3.10/site-packages/offlineimap/repository/IMAP.py", line 672, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/usr/lib/python3.10/site-packages/offlineimap/imapserver.py", line 607, in acquireconnection
    listres = imapobj.list(self.reference, '""')[1]
  File "/usr/lib/python3.10/site-packages/offlineimap/imaplib2.py", line 917, in list
    return self._simple_command(name, directory, pattern, **kw)
  File "/usr/lib/python3.10/site-packages/offlineimap/imaplib2.py", line 1705, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/usr/lib/python3.10/site-packages/offlineimap/imaplib2.py", line 1452, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))

Have you seen this error? Do you have any tips for resolving it? Here is my config:

[general]
accounts = outlook

[Account outlook]
localrepository = outlook-Local
remoterepository = outlook-Remote

[Repository outlook-Local]
type = Maildir
localfolders = ~/Maildir/Outlook

[Repository outlook-Remote]
type = IMAP
sslcacertfile = /etc/pki/tls/certs/ca-bundle.crt
remotehost = outlook.office365.com
remoteuser = <my email address>
# I tried both with and without specifying a password by adding and removing this line:
remotepass = <my password>
auth_mechanisms = XOAUTH2
oauth2_request_url = https://login.microsoftonline.com/common/oauth2/v2.0/token
oauth2_client_id = <thunderbird client_id>
oauth2_client_secret = <thunderbird client_secret>
oauth2_refresh_token = <contents of my imap_smtp_refresh_token file>

Any help would be appreciated!

goomens commented 2 years ago

This error can unfortunately mean a number of things, including invalid credentials or a rate limit. It might also be that IMAP is simply not enabled for this mailbox, check that this is turned on in the Exchange Online admin panel. Finally in the last day or so there was a service disruption in Exchange Online which might also have caused this error, but that should be fixed today.

ragu-manjegowda commented 1 year ago

It happened to me that one or more of Microsoft's servers were down.

If it helps the next person, following helped me fix it.

  1. Get the ip of the server. $ dig +short outlook.office365.com

  2. Force it to use a specific server by adding this line to /etc/hosts, replace XX with one of IPs from above command. XX.XX.XX.XX outlook.office365.com