parent
c8d4e58a93
commit
9a95d738d5
|
@ -242,10 +242,11 @@ def email_imap_alert(username, password, server='imap.gmail.com', port=993, fold
|
||||||
try:
|
try:
|
||||||
mail = imaplib.IMAP4_SSL(server, port)
|
mail = imaplib.IMAP4_SSL(server, port)
|
||||||
mail.login(username, password)
|
mail.login(username, password)
|
||||||
rc, message = mail.status(folder, '(UNSEEN)').decode('utf-8')
|
rc, message = mail.status(folder, '(UNSEEN)')
|
||||||
unread_count = int(re.search('UNSEEN (\d+)', message[0]).group(1))
|
unread_str = message[0].decode('utf-8')
|
||||||
except (imaplib.IMAP4.error, AttributeError):
|
unread_count = int(re.search('UNSEEN (\d+)', unread_str).group(1))
|
||||||
return None
|
except imaplib.IMAP4.error as e:
|
||||||
|
unread_count = str(e)
|
||||||
if not unread_count:
|
if not unread_count:
|
||||||
return None
|
return None
|
||||||
return [{
|
return [{
|
||||||
|
|
Loading…
Reference in New Issue