From f9f9eacd888565660e44ee5119124614dd442e03 Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Sat, 26 Mar 2011 21:31:17 +0100 Subject: IMAP: handle broken servers sending no untagged SEARCH response The proprietary "SmartMail" IMAP server likes to send no untagged SEARCH response when the set of matching email messages is empty. This was brought up as sf.net support request #3213272. --- archivemail | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/archivemail b/archivemail index 58d833d..8c0e2c9 100755 --- a/archivemail +++ b/archivemail @@ -1348,9 +1348,13 @@ def _archive_imap(mailbox_name): result, response = imap_srv.search(None, imap_filter) if result != 'OK': unexpected_error("imap search failed; server says '%s'" % response[0]) - # response is a list with a single item, listing message sequence numbers - # like ['1 2 3 1016'] - message_list = response[0].split() + if response[0] is not None: + # response is a list with a single item, listing message + # sequence numbers like ['1 2 3 1016'] + message_list = response[0].split() + else: + # Broken server has sent no untagged response; assume empty result set. + message_list = [] vprint("%d messages are matching filter" % len(message_list)) # First, gather data for the statistics. -- cgit v1.2.3