Created
August 30, 2012 14:29
-
-
Save vadviktor/3529647 to your computer and use it in GitHub Desktop.
Python: gmail unread E-mail checker
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 | |
def gmail_checker(username,password): | |
import imaplib,re | |
i=imaplib.IMAP4_SSL('imap.gmail.com') | |
try: | |
i.login(username,password) | |
x,y=i.status('INBOX','(MESSAGES UNSEEN)') | |
messages=int(re.search('MESSAGES\s+(\d+)',y[0]).group(1)) | |
unseen=int(re.search('UNSEEN\s+(\d+)',y[0]).group(1)) | |
return (messages,unseen) | |
except: | |
return False,0 | |
messages,unseen = gmail_checker('[email protected]','password') | |
print "%i messages, %i unseen" % (messages,unseen) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SyntaxError: invalid syntax