Handle socket errors in IMAP mail segment

This commit is contained in:
Kim Silkebækken 2013-03-04 15:13:58 +01:00
parent cb87cfbe0f
commit be62815c0b
1 changed files with 2 additions and 0 deletions

View File

@ -478,6 +478,8 @@ def email_imap_alert(username, password, server='imap.gmail.com', port=993, fold
rc, message = mail.status(folder, '(UNSEEN)')
unread_str = message[0].decode('utf-8')
unread_count = int(re.search('UNSEEN (\d+)', unread_str).group(1))
except socket.gaierror:
return None
except imaplib.IMAP4.error as e:
unread_count = str(e)
if not unread_count: