awesome/awesome-wm-widgets/email-widget/count_unread_emails.py

16 lines
299 B
Python
Raw Normal View History

2018-11-28 15:31:35 +01:00
#!/usr/bin/python
import imaplib
import email
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 = counts[0].split()[4][:-1]
else:
unread = "N/A"
print(unread)