Skip to content

Instantly share code, notes, and snippets.

@sebcode
Created April 25, 2011 13:38
Show Gist options
  • Save sebcode/940526 to your computer and use it in GitHub Desktop.
Save sebcode/940526 to your computer and use it in GitHub Desktop.
script to display the number of new messages of an imap mailbox
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