Skip to content

Instantly share code, notes, and snippets.

@dep-deprecated
Created May 29, 2013 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dep-deprecated/5670713 to your computer and use it in GitHub Desktop.
Save dep-deprecated/5670713 to your computer and use it in GitHub Desktop.
This script will pull an 'unread count' from your gmail inbox.
#!/usr/bin/env python -tt
import sys
import curses
import imaplib
import warnings
def main():
imap_server = imaplib.IMAP4_SSL("imap.gmail.com",993)
imap_server.login('username', 'password')
imap_server.select('INBOX')
status, response = imap_server.status('INBOX', "(UNSEEN)")
unreadcount = int(response[0].split()[2].strip(').,]'))
print unreadcount
imap_server.logout()
# This is the standard boilerplate that calls the main() function.
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment