Repository: OfflineIMAP/offlineimap

Issue #291: Error with some folders
Created: 2016-01-06T22:31:33Z
Hello
When sync some folder, I get error:
Syncing Apps/DynaTrace: IMAP -> Maildir
Loading message list for Maildir[Apps/DynaTrace]
Message list for Maildir[Apps/DynaTrace] loaded: 0 messages
[imap]:   16:34.69 Account sync XXX [sync] SELECT ('Apps/DynaTrace',)
[imap]:   16:34.69 Account sync XXX state_change_pending.acquire
[imap]:   16:34.69 Account sync XXX _request_push(CBDM90, SELECT, {}) = CBDM90
[imap]:   16:34.70 Account sync XXX data=CBDM90 SELECT Apps/DynaTrace
[imap]:   16:34.70 Account sync XXX SELECT:CBDM90.ready.wait
imap.XXX.com writer:
[imap]:   16:34.70 imap.XXX.com writer > CBDM90 SELECT Apps/DynaTrace\r\n
imap.XXX.com reader:
[imap]:   16:34.71 imap.XXX.com reader poll => [(4, 1)]
[imap]:   16:34.71 imap.XXX.com reader rcvd 34
[imap]:   16:34.71 imap.XXX.com reader < CBDM90 NO Server Unavailable. 15\r\n
imap.XXX.com handler:
[imap]:   16:34.71 imap.XXX.com handler _put_response(CBDM90 NO Server Unavailable. 15)
[imap]:   16:34.71 imap.XXX.com handler _request_pop(CBDM90, ('NO', ['Server Unavailable. 15'])) [0] = CBDM90
[imap]:   16:34.71 imap.XXX.com handler SELECT:CBDM90.ready.set
[imap]:   16:34.71 imap.XXX.com handler state_change_free.set
[imap]:   16:34.71 imap.XXX.com handler NO response: Server Unavailable. 15
Account sync XXX:
[imap]:   16:34.73 Account sync XXX state => AUTH
[imap]:   16:34.73 Account sync XXX state_change_pending.release
ERROR: Aborting sync, folder 'Apps/DynaTrace' [acc: 'XXX']
Error SELECTing mailbox 'Apps/DynaTrace', server reply:
('NO', ['Server Unavailable. 15'])
['  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 561, in syncfolder\n    check_uid_validity(localfolder, remotefolder, statusfolder)\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 424, in check_uid_validity\n    remotefolder.save_uidvalidity()\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 241, in save_uidvalidity\n    newval = self.get_uidvalidity()\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 106, in get_uidvalidity\n    self.__selectro(imapobj)\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 71, in __selectro\n    imapobj.select(self.getfullname(), force = force)\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/imaplibutil.py", line 65, in select\n    raise OfflineImapError(errstr, severity)\n']
Server is M Exchange, I don't know version (2007?)

Duplicate issue #507: Email from office365.com with event breaks offlineimap
Created: 2017-11-15T14:56:10Z
General informations

system/distribution (with version): Fedora 26
offlineimap version (offlineimap -V):
$ offlineimap -V
offlineimap v7.1.4, imaplib2 v2.57 (bundled), Python v2.7.14, OpenSSL 1.1.0f-fips  25 May 2017


server name or domain: outlook.office365.com
CLI options: offlineimap -a ftgp -1 -d imap -f Archive -o 

Configuration file offlineimaprc
[Repository ftgp-remote]
type = IMAP
auth_mechanisms = PLAIN
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-bundle.crt
remoteuser = MY@EMAIL
remotepasseval = pass_retreive("ftgp/login.microsoftonline.com")
remotehost = outlook.office365.com
remoteport = 993
realdelete = no
folderfilter = lambda folder: folder in [ 'Sent', 'INBOX', 'Archive' ]

Logs, error
offlineimap -a ftgp -1 -d imap -f Archive -o 
OfflineIMAP 7.1.4
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v2.57 (bundled), Python v2.7.14, OpenSSL 1.1.0f-fips  25 May 2017
Debug mode: Forcing to singlethreaded.
Now debugging for imap: IMAP protocol debugging
Now debugging for : Other offlineimap related sync messages
[imap]: Using authentication mechanisms ['PLAIN']
*** Processing account ftgp
Establishing connection to outlook.office365.com:993 (ftgp-remote)
[imap]: ftgp-remote: level 'tls_compat', version 'None'
[imap]: Attempting PLAIN authentication
[imap]: __plainhandler: returning \0My@Email\0(passwd hidden for log)
[]: Filtering out 'Calendar'[ftgp-remote] due to folderfilter
[]: Filtering out 'Calendar/Birthdays'[ftgp-remote] due to folderfilter
[...]
[]: Copying folder structure from ftgp-remote to ftgp-local
Syncing Archive: IMAP -> Maildir
Loading message list for Maildir[Archive]
Message list for Maildir[Archive] loaded: 1014 messages
Loading message list for IMAP[Archive]
[imap]: calling imaplib2 fetch command: '1:*' (FLAGS UID INTERNALDATE)
[imap]: __options2hash returning: {'INTERNALDATE': '"29-Jun-2017 10:37:11 +0200"', 'FLAGS': '(\\Seen)', 'UID': '10687'}
[…]
[imap]: __options2hash returning: {'INTERNALDATE': '"13-Nov-2017 10:32:44 +0100"', 'FLAGS': '(\\Seen \\Answered)', 'UID': '11689'}
Message list for IMAP[Archive] loaded: 994 messages
Syncing messages IMAP[Archive] -> Maildir[Archive]
Syncing messages Maildir[Archive] -> IMAP[Archive]
Copy message UID -20 (1/20) ftgp-local:Archive -> ftgp-remote
[imap]: Write mail 'Archive:-20' with flags set(['S', 'T'])
[]: deletemessageheaders: called to delete []
[]: getmessageheader: called to get message-id
[]: getmessageheader: eoh = 7549
[]: getmessageheader: headers = 'Received: from HE1PR0401MB1963[…]'
[imap]: savemessage: date: "13-Nov-2017 13:51:17 +0100", content: 'Received: from HE1PR0401MB1963.eurprd04.prod.outlook.com (10.166.122.137) by
 VI1PR0401MB1967.eurprd04.prod.outlook.com (10.166.141.7) with Microsoft...B351158EDAA2109298F19C5BDF02B0AM6PR0402MB3511_--
'
ERROR: Saving msg ([unknown message-id]) in folder 'Archive', repository 'ftgp-remote' failed (abort). Server responded: NO ['Server Unavailable. 15']

['  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/accounts.py", line 283, in syncrunner\n    self.__sync()\n', '  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/accounts.py", line 408, in __sync\n    syncfolder(self, remotefolder, quick)\n', '  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/accounts.py", line 643, in syncfolder\n    localfolder.syncmessagesto(remotefolder, statusfolder)\n', '  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 1116, in syncmessagesto\n    action(dstfolder, statusfolder)\n', '  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 944, in __syncmessagesto_copy\n    self.copymessageto(uid, dstfolder, statusfolder, register=0)\n', '  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 844, in copymessageto\n    new_uid = dstfolder.savemessage(uid, message, flags, rtime)\n', '  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 669, in savemessage\n    raise OfflineImapError(msg, OfflineImapError.ERROR.REPO)\n']
*** Finished account 'ftgp' in 0:06
ERROR: Exceptions occurred during the run!
ERROR: Saving msg ([unknown message-id]) in folder 'Archive', repository 'ftgp-remote' failed (abort). Server responded: NO ['Server Unavailable. 15']


Traceback:
  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/accounts.py", line 283, in syncrunner
    self.__sync()
  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/accounts.py", line 408, in __sync
    syncfolder(self, remotefolder, quick)
  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/accounts.py", line 643, in syncfolder
    localfolder.syncmessagesto(remotefolder, statusfolder)
  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 1116, in syncmessagesto
    action(dstfolder, statusfolder)
  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 944, in __syncmessagesto_copy
    self.copymessageto(uid, dstfolder, statusfolder, register=0)
  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 844, in copymessageto
    new_uid = dstfolder.savemessage(uid, message, flags, rtime)
  File "/home/cassou/.local/venvs/offlineimap/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 669, in savemessage
    raise OfflineImapError(msg, OfflineImapError.ERROR.REPO)

Steps to reproduce the error

move locally an email with an event inside from a folder to another one and try to sync with an exchange server

I've been using offlineimap with this server for more than 6 months now. This error started to appear a few weeks ago (potentially with latest release).

Closing comment (2017-11-15T15:14:05Z): This looks similar to #291.
My workaround to get offlineimap sync my emails:

find the offending message by looking at the log for the header "Subject:"
find which file is problematic locally (e.g., using notmuch) and delete it
find which message is problematic on the server (e.g., using webmail) and delete it
try again
repeat all steps until success