mail: Count unread mail from all mailboxes Before it only counted unread mails in the default folder (INBOX), but now I use sieve to sort into subfolders.
1 files changed, 5 insertions(+), 2 deletions(-) M modules/mail.py
M modules/mail.py => modules/mail.py +5 -2
@@ 2,10 2,13 @@ import imaplib def get_unread(ip, port, user, password): count = 0 mail = imaplib.IMAP4_SSL(ip, port) mail.login(user, password) mail.select() count = len(mail.search(None, "UnSeen")[1][0].split()) for folder in mail.list()[1]: foldername = folder.decode().split(' "/" ')[1] mail.select(foldername) count += len(mail.search(None, "UnSeen")[1][0].split()) mail.close() mail.logout() return count