Created
April 25, 2011 13:38
-
-
Save sebcode/940526 to your computer and use it in GitHub Desktop.
script to display the number of new messages of an imap mailbox
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
import sys, imaplib | |
server = '...' | |
user = '...' | |
passwd = '...' | |
try: | |
s = imaplib.IMAP4_SSL(server) | |
s.login(user, passwd) | |
a, b = s.status('INBOX', '(MESSAGES UNSEEN)') | |
print b[0].split(' ')[4].split(')')[0] | |
sys.exit(0) | |
except: | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment