Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

offlineimap fails with error: ID command error: BAD [b'invalid command']. Data: b'OOOK2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n' #133

Closed
robertvalik opened this issue Aug 24, 2022 · 10 comments

Comments

@robertvalik
Copy link

After upgrade from py2 offlineimap to py3 offlineimap3 (git clone from this repo) I am unable to get e-mails from my IMAP server. I tried to "clean up" the existing configuration to a bare minimum provided here, still the error is the same. I am getting this error on my Gentoo machine but also on a Debian running in WSL...

General informations

  • system/distribution (with version): Gentoo
  • offlineimap version (offlineimap -V): offlineimap v8.0.0, imaplib2 v3.06, Python v3.10.5, OpenSSL 1.1.1q 5 Jul 2022
  • Python version: Python 3.10.5
  • server name or domain: private, running on Mailu docker installation (will provide address + account if needed)
  • CLI options: -u basic -dALL

Configuration file offlineimaprc

[general]
accounts = example_com_bare

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

[Repository example_com_bare-Local]
type = Maildir
localfolders = ~/.mail/example_com_bare

[Repository example_com_bare-Remote]
type = IMAP
remoteuser = user@example.sk
remotehost = example.com
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
remotepass = adasuaihdauidahdalhdaaslda

Logs, error

OfflineIMAP 8.0.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.06, Python v3.10.5, OpenSSL 1.1.1q  5 Jul 2022
Now debugging for imap: IMAP protocol debugging
Now debugging for maildir: Maildir repository debugging
Now debugging for thread: Threading debugging
Now debugging for : Other offlineimap related sync messages
[thread]: Register new thread 'Account sync example_com_bare' (account 'example_com_bare')
[imap]: Using authentication mechanisms ['GSSAPI', 'XOAUTH2', 'CRAM-MD5', 'PLAIN', 'LOGIN']
[maildir]: MaildirRepository initialized, sep is '.'
*** Processing account example_com_bare
Establishing connection to example.com:993 (example_com_bare-Remote)
[imap]: example_com_bare-Remote: level 'tls_compat', version 'None'
[imap]:   19:30.00 Account sync example_com_bare imaplib2 version 3.06
[imap]:   19:30.00 Account sync example_com_bare imaplib2 debug level 5, buffer level 3
[imap]:   19:30.02 Account sync example_com_bare connected to example.com on port 993
[imap]:   19:30.02 example.com writer starting
[imap]:   19:30.02 example.com reader starting using poll
[imap]:   19:30.02 example.com reader poll => [(5, 1)]
[imap]:   19:30.02 Account sync example_com_bare _request_push(continuation, welcome, {}) = b'OOOK0'
[imap]:   19:30.02 Account sync example_com_bare welcome:b'OOOK0'.ready.wait
[imap]:   19:30.06 example.com reader rcvd 18
[imap]:   19:30.06 example.com reader < b'* OK IMAP4 ready\r\n'
[imap]:   19:30.12 example.com handler starting
[imap]:   19:30.12 example.com handler _put_response(b'* OK IMAP4 ready')
[imap]:   19:30.12 example.com handler untagged_responses[OK] 0 += ["b'IMAP4 ready'"]
[imap]:   19:30.12 example.com handler _request_pop(continuation, (False, b'* OK IMAP4 ready')) [0] = b'OOOK0'
[imap]:   19:30.12 example.com handler welcome:b'OOOK0'.ready.set
[imap]:   19:30.12 example.com handler state_change_free.set
[imap]:   19:30.12 Account sync example_com_bare _get_untagged_response(OK) => [b'IMAP4 ready']
[imap]:   19:30.12 Account sync example_com_bare state => NONAUTH
[imap]:   19:30.12 Account sync example_com_bare [async] CAPABILITY ()
[imap]:   19:30.12 Account sync example_com_bare state_change_pending.acquire
[imap]:   19:30.12 Account sync example_com_bare state_change_pending.release
[imap]:   19:30.12 Account sync example_com_bare _request_push(b'OOOK1', CAPABILITY, {}) = b'OOOK1'
[imap]:   19:30.12 Account sync example_com_bare data=b'OOOK1 CAPABILITY'
[imap]:   19:30.12 Account sync example_com_bare CAPABILITY:b'OOOK1'.ready.wait
[imap]:   19:30.12 example.com writer > b'OOOK1 CAPABILITY\r\n'
[imap]:   19:30.12 example.com reader poll => [(5, 1)]
[imap]:   19:30.12 example.com reader rcvd 117
[imap]:   19:30.12 example.com reader < b'* CAPABILITY IMAP4 IMAP4rev1 UIDPLUS SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN\r\n'
[imap]:   19:30.12 example.com reader < b'OOOK1 OK completed\r\n'
[imap]:   19:30.12 example.com handler _put_response(b'* CAPABILITY IMAP4 IMAP4rev1 UIDPLUS SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN')
[imap]:   19:30.12 example.com handler untagged_responses[CAPABILITY] 0 += ["b'IMAP4 IMAP4rev1 UIDPLUS SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=P"]
[imap]:   19:30.12 example.com handler _put_response(b'OOOK1 OK completed')
[imap]:   19:30.12 example.com handler _request_pop(b'OOOK1', ('OK', [b'completed'])) [0] = b'OOOK1'
[imap]:   19:30.12 example.com handler CAPABILITY:b'OOOK1'.ready.set
[imap]:   19:30.12 example.com handler state_change_free.set
[imap]:   19:30.12 Account sync example_com_bare _get_untagged_response(CAPABILITY) => [b'IMAP4 IMAP4rev1 UIDPLUS SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=
[imap]:   19:30.13 Account sync example_com_bare _untagged_response(OK, ?, CAPABILITY) => [b'IMAP4 IMAP4rev1 UIDPLUS SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=
[imap]:   19:30.13 Account sync example_com_bare CAPABILITY: ('IMAP4', 'IMAP4REV1', 'UIDPLUS', 'SASL-IR', 'LOGIN-REFERRALS', 'ID', 'ENABLE', 'IDLE', 'LITERAL+', 'AUTH=PLAIN')
[imap]:   19:30.13 Account sync example_com_bare [async] ID ('("name" "OfflineIMAP" "version" "8.0.0")',)
[imap]:   19:30.13 Account sync example_com_bare state_change_pending.acquire
[imap]:   19:30.13 Account sync example_com_bare state_change_pending.release
[imap]:   19:30.13 Account sync example_com_bare _request_push(b'OOOK2', ID, {}) = b'OOOK2'
[imap]:   19:30.13 Account sync example_com_bare data=b'OOOK2 ID ("name" "OfflineIMAP" "version" "8.0.0")'
[imap]:   19:30.13 Account sync example_com_bare ID:b'OOOK2'.ready.wait
[imap]:   19:30.13 example.com writer > b'OOOK2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'
[imap]:   19:30.13 example.com reader poll => [(5, 1)]
[imap]:   19:30.13 example.com reader rcvd 27
[imap]:   19:30.13 example.com reader < b'OOOK2 BAD invalid command\r\n'
[imap]:   19:30.13 example.com handler _put_response(b'OOOK2 BAD invalid command')
[imap]:   19:30.13 example.com handler _request_pop(b'OOOK2', ('BAD', [b'invalid command'])) [0] = b'OOOK2'
[imap]:   19:30.13 example.com handler ID:b'OOOK2'.ready.set
[imap]:   19:30.13 example.com handler state_change_free.set
[imap]:   19:30.13 example.com handler BAD response: b'invalid command'
[imap]:   19:30.13 Account sync example_com_bare last 20 log messages:
[imap]:   19:30.02 example.com writer starting
[imap]:   19:30.02 example.com reader starting using poll
[imap]:   19:30.12 example.com handler starting
[imap]:   19:30.12 Account sync example_com_bare state => NONAUTH
[imap]:   19:30.12 Account sync example_com_bare [async] CAPABILITY ()
[imap]:   19:30.13 Account sync example_com_bare CAPABILITY: ('IMAP4', 'IMAP4REV1', 'UIDPLUS', 'SASL-IR', 'LOGIN-REFERRALS', 'ID', 'ENABLE', 'IDLE', 'LITERAL+', 'AUTH=PLAIN')
[imap]:   19:30.13 Account sync example_com_bare [async] ID ('("name" "OfflineIMAP" "version" "8.0.0")',)
[imap]:   19:30.13 example.com handler BAD response: b'invalid command'
ERROR: While attempting to sync account 'example_com_bare'
  ID command error: BAD [b'invalid command']. Data: b'OOOK2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'
['  File "/home/user/Applications/OfflineImap/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner\n    self.__sync()\n', '  File "/home/user/Applications/OfflineImap/offlineimap3/offlineimap/accounts.py", line 375, in __sync\n    remoterepos.getfolders()\n', '  File "/home/user/Applications/OfflineImap/offlineimap3/offlineimap/repository/IMAP.py", line 681, in getfolders\n    imapobj = self.imapserver.acquireconnection()\n', '  File "/home/user/Applications/OfflineImap/offlineimap3/offlineimap/imapserver.py", line 589, in acquireconnection\n    imapobj.id(l_str)\n', '  File "/home/user/.local/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 889, in id\n    return self._simple_command(name, data, **kw)\n', '  File "/home/user/.local/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 1705, in _simple_command\n    return self._command_complete(self._command(name, *args), kw)\n', '  File "/home/user/.local/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 1452, in _command_complete\n    raise self.error(\'%s command error: %s %s. Data: %.100s\' % (rqb.name, typ, dat, rqb.data))\n']
*** Finished account 'example_com_bare' in 0:00
[thread]: Unregister thread 'Account sync example_com_bare'
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'example_com_bare'
  ID command error: BAD [b'invalid command']. Data: b'OOOK2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'

Traceback:
  File "/home/user/Applications/OfflineImap/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File "/home/user/Applications/OfflineImap/offlineimap3/offlineimap/accounts.py", line 375, in __sync
    remoterepos.getfolders()
  File "/home/user/Applications/OfflineImap/offlineimap3/offlineimap/repository/IMAP.py", line 681, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/home/user/Applications/OfflineImap/offlineimap3/offlineimap/imapserver.py", line 589, in acquireconnection
    imapobj.id(l_str)
  File "/home/user/.local/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 889, in id
    return self._simple_command(name, data, **kw)
  File "/home/user/.local/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 1705, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/home/user/.local/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 1452, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))

Steps to reproduce the error

  • Running the offlineimap with provided config and attributes
@drtutut
Copy link

drtutut commented Sep 1, 2022

Same problem for me, except that I installed offlineimap3 on a brand new machine.
General informations

  • system/distribution (with version): Debian 11.3
  • offlineimap version (offlineimap -V): offlineimap v8.0.0, imaplib2 v3.05, Python v3.9.2, OpenSSL 1.1.1n 15 Mar 2022
  • Python version: Python 3.9.2
  • server name or domain:
  • CLI options: -1 -l ~/local/log/offlineimap.log

Log file shows same error as @robertvalik (except that the letters before the "ID" in the Data field are different):

ID command error: BAD [b'invalid command']. Data: b'BPIO2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'

I have two IMAP accounts configured, one of them works perfectly (imap.ionos.de), the other raises the error (imap.univ-amu.fr).

@robertvalik
Copy link
Author

except that the letters before the "ID" in the Data field are different

@drtutut Yes, that string changes every time I run offlineimap.

@mborko
Copy link

mborko commented Sep 8, 2022

I am getting the same error (Mailserver is a Mailu Instance):

OfflineIMAP 8.0.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.05, Python v3.10.6, OpenSSL 3.0.5 5 Jul 2022
Account sync systemmanufaktur.at:
 *** Processing account systemmanufaktur.at
 Establishing connection to mail.systemmanufaktur.at:993 (remoteSysmanu)
 ERROR: While attempting to sync account 'systemmanufaktur.at'
  ID command error: BAD [b'invalid command']. Data: b'HCOH2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'
 *** Finished account 'systemmanufaktur.at' in 0:00
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'systemmanufaktur.at'
  ID command error: BAD [b'invalid command']. Data: b'HCOH2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'

Traceback:
  File "/usr/share/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File "/usr/share/offlineimap3/offlineimap/accounts.py", line 374, in __sync
    remoterepos.getfolders()
  File "/usr/share/offlineimap3/offlineimap/repository/IMAP.py", line 681, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 589, in acquireconnection
    imapobj.id(l_str)
  File "/usr/lib/python3/dist-packages/imaplib2.py", line 868, in id
    return self._simple_command(name, data, **kw)
  File "/usr/lib/python3/dist-packages/imaplib2.py", line 1684, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/usr/lib/python3/dist-packages/imaplib2.py", line 1431, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))

and with a newer version of imaplib2 too:

OfflineIMAP 8.0.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.06, Python v3.10.6, OpenSSL 1.1.1q  5 Jul 2022
Account sync systemmanufaktur.at:
 *** Processing account systemmanufaktur.at
 Establishing connection to mail.systemmanufaktur.at:143 (remoteSysmanu)
 ERROR: While attempting to sync account 'systemmanufaktur.at'
  ID command error: BAD [b'invalid command']. Data: b'PGGP2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'
 *** Finished account 'systemmanufaktur.at' in 0:00
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'systemmanufaktur.at'
  ID command error: BAD [b'invalid command']. Data: b'PGGP2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'

Traceback:
  File "/home/mike/repositories/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File "/home/mike/repositories/offlineimap3/offlineimap/accounts.py", line 375, in __sync
    remoterepos.getfolders()
  File "/home/mike/repositories/offlineimap3/offlineimap/repository/IMAP.py", line 681, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/home/mike/repositories/offlineimap3/offlineimap/imapserver.py", line 589, in acquireconnection
    imapobj.id(l_str)
  File "/home/mike/repositories/offlineimap3/venv/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 889, in id
    return self._simple_command(name, data, **kw)
  File "/home/mike/repositories/offlineimap3/venv/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 1705, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/home/mike/repositories/offlineimap3/venv/lib/python3.10/site-packages/imaplib2/imaplib2.py", line 1452, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))

@elia-blue
Copy link

Hej,
are there any recent updates to this issue? I'm having the same problem, where OfflineIMAP just refuses to work with Mailu as a server.

Error log:

OfflineIMAP 8.0.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.06, Python v3.11.1, OpenSSL 1.1.1s  1 Nov 2022
*** Processing account elia_blue_noby
Establishing connection to mail.epicblu.net:993 (elia_blue_noby_remote)
ERROR: While attempting to sync account 'elia_blue_noby'
  ID command error: BAD [b'invalid command']. Data: b'LKIN2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'
*** Finished account 'elia_blue_noby' in 0:00
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'elia_blue_noby'
  ID command error: BAD [b'invalid command']. Data: b'LKIN2 ID ("name" "OfflineIMAP" "version" "8.0.0")\r\n'

Traceback:
  File "/opt/homebrew/Cellar/offlineimap/8.0.0_1/libexec/lib/python3.11/site-packages/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File "/opt/homebrew/Cellar/offlineimap/8.0.0_1/libexec/lib/python3.11/site-packages/offlineimap/accounts.py", line 374, in __sync
    remoterepos.getfolders()
  File "/opt/homebrew/Cellar/offlineimap/8.0.0_1/libexec/lib/python3.11/site-packages/offlineimap/repository/IMAP.py", line 681, in getfolders
    imapobj = self.imapserver.acquireconnection()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/offlineimap/8.0.0_1/libexec/lib/python3.11/site-packages/offlineimap/imapserver.py", line 589, in acquireconnection
    imapobj.id(l_str)
  File "/opt/homebrew/Cellar/offlineimap/8.0.0_1/libexec/lib/python3.11/site-packages/imaplib2/imaplib2.py", line 889, in id
    return self._simple_command(name, data, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/offlineimap/8.0.0_1/libexec/lib/python3.11/site-packages/imaplib2/imaplib2.py", line 1705, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/offlineimap/8.0.0_1/libexec/lib/python3.11/site-packages/imaplib2/imaplib2.py", line 1452, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))

@mborko
Copy link

mborko commented Feb 2, 2023

Hej, are there any recent updates to this issue? I'm having the same problem, where OfflineIMAP just refuses to work with Mailu as a server.

Sorry, I have still the same problem, but I have a question: Do you also use traefik as loadbalancer, or do you have Mailu with the front container only?

@mborko
Copy link

mborko commented Feb 15, 2023

Hej,
are there any recent updates to this issue? I'm having the same problem, where OfflineIMAP just refuses to work with Mailu as a server.

FYI, I've decided to switch to isync and the mbsync Tool (see the manpage and short overview from arch-wiki). It was quite easy to configure the tool, but be aware of the directions (far near both). I need it for a mail server portation, and I tested it with two new mailboxes before I will now start to port my main accounts.

It is a pity, offlineimap seems orphaned!

@robertvalik
Copy link
Author

I've decided to switch to isync and the mbsync

Yup, I did the same to work around the OfflineIMAP problem. I believe it could be the recommended solution.

@sholl
Copy link

sholl commented Sep 15, 2023

I also have this issue when trying to connect to a Mailu 2.0-Server-instance. Any hints? I am not that keen to switch to isync as others suggested though. This setup used to work against a mailu-1.9 instance, offlineimap running on Debian 11.x.

@thekix
Copy link
Member

thekix commented Nov 22, 2023

Hi,

sorry about the delay.

Please, could you try the latest offlineimap3 from github and send the output of offlineimap3 -1 -d ALL (REMOVE YOUR SENSITIVE DATA)

Best regards,
kix

@sholl
Copy link

sholl commented Nov 22, 2023

it turns out that my mail-stack hat a wrong capabilities-entry which leads offlineimap to fail. This is fixed in the meantime, so I will close this issue now. Thanks for the heads-up.

@thekix thekix closed this as completed Nov 22, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants