From 96cae9bdd5132d5a4468d9d18c647bd2431e9f03 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Wed, 13 Sep 2017 01:44:36 -0400 Subject: [PATCH] Added better logging for case when IMAP folder may not exist when check IMAP messages, to address issue in #536 --- helpdesk/management/commands/get_email.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index 4b979fcc..476c7d89 100755 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -195,7 +195,10 @@ def process_queue(q, logger): settings.QUEUE_EMAIL_BOX_PASSWORD) server.select(q.email_box_imap_folder) - status, data = server.search(None, 'NOT', 'DELETED') + try: + status, data = server.search(None, 'NOT', 'DELETED') + except imaplib.IMAP4.error: + logger.error("IMAP retrieve failed. Is the folder '%s' spelled correctly, and does it exist on the server?" % q.email_box_imap_folder) if data: msgnums = data[0].split() logger.info("Received %d messages from IMAP server" % len(msgnums))