From 194aa1db3c261bc581b466dd9898ebadce024246 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Mon, 15 Aug 2011 10:18:37 +0200 Subject: [PATCH] Catch 'BAD' replies on append()ing a message append() raises an Exception, in case the IMAP server replies with 'BAD' (but not when it responds with 'NO') but we were not catching that. Do catch the situation and also raise an OfflineImapError at MESSAGE severity, so that we can continue with the next message. Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/IMAP.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 6bb9cfb..b4120a6 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -454,9 +454,14 @@ class IMAPFolder(BaseFolder): (date, dbg_output)) #Do the APPEND - (typ, dat) = imapobj.append(self.getfullname(), + try: + (typ, dat) = imapobj.append(self.getfullname(), imaputil.flagsmaildir2imap(flags), date, content) + except Exception, e: + # If the server responds with 'BAD', append() raise()s directly. + # So we need to prepare a response ourselves. + typ, dat = 'BAD', str(e) if typ != 'OK': #APPEND failed raise OfflineImapError("Saving msg in folder '%s', repository " "'%s' failed. Server reponded; %s %s\nMessage content was:"