Comments (8)
Thank you very much. I confirm that offlineimap3 works with imap.163.com now.
from offlineimap3.
Dear @xianwenchen
please, could you test it? Could you add these lines in the file offlineimap/imapserver.py? If you need help, please do not hesitate in write me.
diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index 6acb331..e15d5de 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -586,6 +586,11 @@ class IMAPServer:
af=self.af,
)
+ # If 'ID' extension is used by the server, we should use it
+ # We didn't send any info.
+ if 'ID' in imapobj.capabilities:
+ imapobj.id()
+
if not self.preauth_tunnel:
try:
self.__authn_helper(imapobj)
from offlineimap3.
Thank you.
I tried the patch. It didn't work.
I wonder if it is possible to have a code like this, before selecting an IMAP folder:
If email domain is 163.com:
server.id_({"name": "IMAPClient", "version": "2.1.0"})
from offlineimap3.
Hi @xianwenchen
no, we should provide a standard method, for all servers. Using your patch and mine, could you try this:
diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index 6acb331..e15d5de 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -586,6 +586,11 @@ class IMAPServer:
af=self.af,
)
+ # If 'ID' extension is used by the server, we should use it
+ # We didn't send any info.
+ if 'ID' in imapobj.capabilities:
+ imapobj.id({"name": "IMAPClient", "version": "2.1.0"})
+
if not self.preauth_tunnel:
try:
self.__authn_helper(imapobj)
Thanks,
kix
from offlineimap3.
For your info, connecting to imap.163.com port 143:
* OK Coremail System IMap Server Ready(163com[10774b260cc7a37d26d71b52404dcf5c])
abcd CAPABILITY
* CAPABILITY IMAP4rev1 XLIST SPECIAL-USE ID LITERAL+ STARTTLS APPENDLIMIT=71680000 XAPPLEPUSHSERVICE UIDPLUS X-CM-EXT-1
abcd OK CAPABILITY completed
abcd ID NIL
* ID ("name" "Coremail Imap" "vendor" "Mailtech" "TransID" "I082JmAAABqnFWEI7zcA")
abcd OK ID completed
Cheers,
kix
from offlineimap3.
Anyway, please include the logs, with the -dimap flag.
Thanks
kix
from offlineimap3.
Thank you.
I committed your suggestion to my fork: xianwenchen@01113a0
The code snippet that I copied from the blog post, which I posted initially, was from last year. It could be that the workaround was not working.
The error now seems to be:
ERROR: While attempting to sync account '[email protected]'
can't concat dict to bytes
Below is the full log, including the errors.
OfflineIMAP 7.3.0
Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.06, Python v3.9.6, OpenSSL 1.1.1k 25 Mar 2021
Debug mode: Forcing to singlethreaded.
Now debugging for imap: IMAP protocol debugging
Now debugging for : Other offlineimap related sync messages
Account sync [email protected]:
[imap]: Using authentication mechanisms ['GSSAPI', 'XOAUTH2', 'CRAM-MD5', 'PLAIN', 'LOGIN']
*** Processing account [email protected]
Establishing connection to imap.163.com:993 ([email protected]_remote)
[imap]: [email protected]_remote: level 'tls_compat', version 'None'
[imap]: 57:29.92 Account sync [email protected] imaplib2 version 3.06
[imap]: 57:29.92 Account sync [email protected] imaplib2 debug level 5, buffer level 3
[imap]: 57:30.41 Account sync [email protected] connected to imap.163.com on port 993
imap.163.com writer:
[imap]: 57:30.41 imap.163.com writer starting
imap.163.com reader:
[imap]: 57:30.41 imap.163.com reader starting using poll
Account sync [email protected]:
[imap]: 57:30.41 Account sync [email protected] _request_push(continuation, welcome, {}) = b'DIJJ0'
[imap]: 57:30.41 Account sync [email protected] welcome:b'DIJJ0'.ready.wait
imap.163.com handler:
[imap]: 57:30.51 imap.163.com handler starting
imap.163.com reader:
[imap]: 57:30.63 imap.163.com reader poll => [(5, 1)]
[imap]: 57:30.63 imap.163.com reader rcvd 82
[imap]: 57:30.63 imap.163.com reader < b'* OK Coremail System IMap Server Ready(163com[10774b260cc7a37d26d71b52404dcf5c])\r\n'
imap.163.com handler:
[imap]: 57:30.63 imap.163.com handler _put_response(b'* OK Coremail System IMap Server Ready(163com[10774b260cc7a37d26d71b52404dcf5c])')
[imap]: 57:30.63 imap.163.com handler untagged_responses[OK] 0 += ["b'Coremail System IMap Server Ready(163com[10774b260cc7a37d26d71b52404dcf5c])'"]
[imap]: 57:30.63 imap.163.com handler _request_pop(continuation, (False, b'* OK Coremail System IMap Server Ready(163com[10774b260cc7a37d26d71b52404dcf5c])')) [0] = b'DIJJ0'
[imap]: 57:30.63 imap.163.com handler welcome:b'DIJJ0'.ready.set
Account sync [email protected]:
[imap]: 57:30.63 Account sync [email protected] _get_untagged_response(OK) => [b'Coremail System IMap Server Ready(163com[10774b260cc7a37d26d71b52404dcf5c])']
imap.163.com handler:
[imap]: 57:30.63 imap.163.com handler state_change_free.set
Account sync [email protected]:
[imap]: 57:30.63 Account sync [email protected] state => NONAUTH
[imap]: 57:30.64 Account sync [email protected] [async] CAPABILITY ()
[imap]: 57:30.64 Account sync [email protected] state_change_pending.acquire
[imap]: 57:30.64 Account sync [email protected] state_change_pending.release
[imap]: 57:30.64 Account sync [email protected] _request_push(b'DIJJ1', CAPABILITY, {}) = b'DIJJ1'
[imap]: 57:30.64 Account sync [email protected] data=b'DIJJ1 CAPABILITY'
[imap]: 57:30.64 Account sync [email protected] CAPABILITY:b'DIJJ1'.ready.wait
imap.163.com writer:
[imap]: 57:30.64 imap.163.com writer > b'DIJJ1 CAPABILITY\r\n'
imap.163.com reader:
[imap]: 57:30.86 imap.163.com reader poll => [(5, 1)]
[imap]: 57:30.86 imap.163.com reader rcvd 152
[imap]: 57:30.86 imap.163.com reader < b'* CAPABILITY IMAP4rev1 XLIST SPECIAL-USE ID LITERAL+ STARTTLS APPENDLIMIT=71680000 XAPPLEPUSHSERVICE UIDPLUS X-CM-EXT-1\r\n'
[imap]: 57:30.86 imap.163.com reader < b'DIJJ1 OK CAPABILITY completed\r\n'
imap.163.com handler:
[imap]: 57:30.86 imap.163.com handler _put_response(b'* CAPABILITY IMAP4rev1 XLIST SPECIAL-USE ID LITERAL+ STARTTLS APPENDLIMIT=71680000 XAPPLEPUSHSERVICE UIDPLUS X-CM-EXT-1')
[imap]: 57:30.86 imap.163.com handler untagged_responses[CAPABILITY] 0 += ["b'IMAP4rev1 XLIST SPECIAL-USE ID LITERAL+ STARTTLS APPENDLIMIT=71680000 XAPPLEPU"]
[imap]: 57:30.86 imap.163.com handler _put_response(b'DIJJ1 OK CAPABILITY completed')
[imap]: 57:30.86 imap.163.com handler _request_pop(b'DIJJ1', ('OK', [b'CAPABILITY completed'])) [0] = b'DIJJ1'
[imap]: 57:30.86 imap.163.com handler CAPABILITY:b'DIJJ1'.ready.set
Account sync [email protected]:
[imap]: 57:30.86 Account sync [email protected] _get_untagged_response(CAPABILITY) => [b'IMAP4rev1 XLIST SPECIAL-USE ID LITERAL+ STARTTLS APPENDLIMIT=71680000 XAPPLEP
imap.163.com handler:
[imap]: 57:30.86 imap.163.com handler state_change_free.set
Account sync [email protected]:
[imap]: 57:30.86 Account sync [email protected] _untagged_response(OK, ?, CAPABILITY) => [b'IMAP4rev1 XLIST SPECIAL-USE ID LITERAL+ STARTTLS APPENDLIMIT=71680000 XAPPLEP
[imap]: 57:30.86 Account sync [email protected] CAPABILITY: ('IMAP4REV1', 'XLIST', 'SPECIAL-USE', 'ID', 'LITERAL+', 'STARTTLS', 'APPENDLIMIT=71680000', 'XAPPLEPUSHSERVICE', 'UIDPLUS', 'X-CM-EXT-1')
[imap]: 57:30.86 Account sync [email protected] [async] ID ({'name': 'IMAPClient', 'version': '2.1.0'},)
[imap]: 57:30.87 Account sync [email protected] state_change_pending.acquire
[imap]: 57:30.87 Account sync [email protected] state_change_pending.release
[imap]: 57:30.87 Account sync [email protected] _request_push(b'DIJJ2', ID, {}) = b'DIJJ2'
ERROR: While attempting to sync account '[email protected]'
can't concat dict to bytes
[' File "/home/c/data/programming/python/offlineimap3-xc/offlineimap/accounts.py", line 298, in syncrunner\n self.__sync()\n', ' File "/home/c/data/programming/python/offlineimap3-xc/offlineimap/accounts.py", line 374, in __sync\n remoterepos.getfolders()\n', ' File "/home/c/data/programming/python/offlineimap3-xc/offlineimap/repository/IMAP.py", line 672, in getfolders\n imapobj = self.imapserver.acquireconnection()\n', ' File "/home/c/data/programming/python/offlineimap3-xc/offlineimap/imapserver.py", line 592, in acquireconnection\n imapobj.id({"name": "IMAPClient", "version": "2.1.0"})\n', ' File "/home/c/.local/lib/python3.9/site-packages/imaplib2/imaplib2.py", line 889, in id\n return self._simple_command(name, data, **kw)\n', ' File "/home/c/.local/lib/python3.9/site-packages/imaplib2/imaplib2.py", line 1705, in _simple_command\n return self._command_complete(self._command(name, *args), kw)\n', ' File "/home/c/.local/lib/python3.9/site-packages/imaplib2/imaplib2.py", line 1384, in _command\n data = data + b\' \' + arg\n']
*** Finished account '[email protected]' in 0:00
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account '[email protected]'
can't concat dict to bytes
Traceback:
File "/home/c/data/programming/python/offlineimap3-xc/offlineimap/accounts.py", line 298, in syncrunner
self.__sync()
File "/home/c/data/programming/python/offlineimap3-xc/offlineimap/accounts.py", line 374, in __sync
remoterepos.getfolders()
File "/home/c/data/programming/python/offlineimap3-xc/offlineimap/repository/IMAP.py", line 672, in getfolders
imapobj = self.imapserver.acquireconnection()
File "/home/c/data/programming/python/offlineimap3-xc/offlineimap/imapserver.py", line 592, in acquireconnection
imapobj.id({"name": "IMAPClient", "version": "2.1.0"})
File "/home/c/.local/lib/python3.9/site-packages/imaplib2/imaplib2.py", line 889, in id
return self._simple_command(name, data, **kw)
File "/home/c/.local/lib/python3.9/site-packages/imaplib2/imaplib2.py", line 1705, in _simple_command
return self._command_complete(self._command(name, *args), kw)
File "/home/c/.local/lib/python3.9/site-packages/imaplib2/imaplib2.py", line 1384, in _command
data = data + b' ' + arg
from offlineimap3.
Dear @xianwenchen
please, could you try this code:
diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index 6acb331..d9de14c 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -586,6 +586,12 @@ class IMAPServer:
af=self.af,
)
+ # If 'ID' extension is used by the server, we should use it
+ if 'ID' in imapobj.capabilities:
+ l_str = '("name" "OfflineIMAP" "version" "{}")'.format(offlineimap.__version__)
+ imapobj.id(l_str)
+
if not self.preauth_tunnel:
try:
self.__authn_helper(imapobj)
If it fails, we can use the NIL option, using this code:
diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index 6acb331..e15d5de 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -586,6 +586,11 @@ class IMAPServer:
af=self.af,
)
+ # If 'ID' extension is used by the server, we should use it
+ # We didn't send any info.
+ if 'ID' in imapobj.capabilities:
+ imapobj.id()
+
if not self.preauth_tunnel:
try:
self.__authn_helper(imapobj)
These are the options first and third of this code of imaplib2 (line 882):
if not kv_pairs:
data = 'NIL'
elif len(kv_pairs) == 1:
data = kv_pairs[0] # Assume invoker passing correctly formatted string (back-compat)
else:
data = '(%s)' % ' '.join([(arg and self._quote(arg) or 'NIL') for arg in kv_pairs])
Best regards,
kix
from offlineimap3.
Related Issues (20)
- Why does the readme recommend an AUR package? HOT 3
- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed error HOT 4
- Offlineimap config files not stored when installing via `pip` HOT 7
- APPEND command error: BAD ['invalid rfc5322 message: Sender should not be present if equal to From'] HOT 3
- offlineimap3 produces error due to defect in Spam email HOT 6
- Support py3.12 HOT 1
- ERROR: UID 11544 has defects preventing it from being processed! HOT 2
- No module named commands error (Debian) HOT 1
- Syncronization of previously deleted/moved emails: 'failed to label messages: Message does not exist'
- "tmp" folder conflicts with mapfilenametmp
- keyring has broken user environment and scripts HOT 2
- Imaputil quote function should escape backslashes first and then quotes
- TypeError: decoding with '136' codec failed (TypeError: utf7m_decode() takes 1 positional argument but 2 were given)
- Document reasoning for having maxsyncaccounts
- IMAP <> IMAP sync introduces a large fixed offset for the received date-time when mail headers contain a negative timezone (eg a USA-based remote mail host). HOT 1
- IMAP with outlook.office365.com and XOAUTH2 fails since 18-Feb-2024 with `command LIST illegal in state NONAUTH`
- Cannot handle 'already exists' and 'Cannot create this folder' messages when syncing folders with Courier IMAP
- Incompatible with Python 3.12 HOT 4
- KeyError: 'cygwin' when installing
- openssl password decryption error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from offlineimap3.