.awesome/gmail_unread.py

17 lines
412 B
Python
Raw Normal View History

2014-08-15 00:06:35 +04:00
#!/usr/bin/python
# Create credentials.py with gmail_login and gmail_password variables
import imaplib
2014-08-15 09:28:31 +04:00
try:
from credentials import gmail_login,gmail_password
M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
M.login(gmail_login,gmail_password)
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
unread = counts[0].split()[4][:-1]
M.logout()
print(int(unread))
except:
print("?")