[PATCH] Increase compatability with Gmail

Sebastian Spaeth Sebastian at SSpaeth.de
Fri Mar 25 09:19:30 GMT 2011

When uploading a new message to Gmail we need to find out the UID it
assigned it, but Gmail does not advertize the UIDPLUS extension (in all
cases) and it fails to find the email that we just uploaded when
searching for it. This prevented us effectively from uploading to

See analysis in
for details on what is going wrong.

This patch increases compatability with Gmail by checking for APPENDUID
responses to an APPEND action even if the server did not claim to
support it. This restores the capability to upload messages to the
*broken* Gmail IMAP implementation.

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
 Changelog.draft.rst        |    3 +++
 offlineimap/folder/IMAP.py |    5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Changelog.draft.rst b/Changelog.draft.rst
index bb63372..6b9d918 100644
--- a/Changelog.draft.rst
+++ b/Changelog.draft.rst
@@ -16,6 +16,9 @@ New Features
+* Increase compatability with Gmail servers which claim to not support
+  the UIDPLUS extension but in reality do.
 Bug Fixes
diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index 74a9b87..828070c 100644
--- a/offlineimap/folder/IMAP.py
+++ b/offlineimap/folder/IMAP.py
@@ -439,8 +439,9 @@ class IMAPFolder(BaseFolder):
             (typ,dat) = imapobj.check()
             assert(typ == 'OK')
-            # get the UID.
-            if use_uidplus:
+            # get the new UID. Test for APPENDUID response even if the
+            # server claims to not support it, as e.g. Gmail does :-(
+            if use_uidplus or imapobj._get_untagged_response('APPENDUID', True):
                 # get the new UID from the APPENDUID response, it could look like
                 # OK [APPENDUID 38505 3955] APPEND completed
                 # with 38505 bein folder UIDvalidity and 3955 the new UID

More information about the OfflineIMAP-project mailing list