Created
September 18, 2012 04:06
-
-
Save mrtazz/3741193 to your computer and use it in GitHub Desktop.
quick script to check unread count of imap inbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
small script to check for unread count on imap inbox | |
""" | |
import imaplib | |
IMAPSERVER = '' | |
USER = '' | |
PASSWORD = '' | |
try: | |
mail = imaplib.IMAP4_SSL(IMAPSERVER) | |
mail.login(USER, PASSWORD) | |
mail.select("inbox", True) # connect to inbox. | |
return_code, mail_ids = mail.search(None, 'UnSeen') | |
count = len(mail_ids[0].split(" ")) | |
except: | |
count = 0 | |
print count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment