summaryrefslogtreecommitdiff
path: root/email-widget/count_unread_emails.py
blob: a8438141a5c6a781b82c967a479d02dcc37aac4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/python

import imaplib
import re

M=imaplib.IMAP4_SSL("mail.teenagemutantninjaturtles.com", 993)
M.login("mickey@tmnt.com","cowabunga")

status, counts = M.status("INBOX","(MESSAGES UNSEEN)")

if status == "OK":
	unread = re.search(r'UNSEEN\s(\d+)', counts[0].decode('utf-8')).group(1)
else:
	unread = "N/A"

print(unread)