Created
July 4, 2017 14:18
-
-
Save jfcarr/07dfc5717f157816da99aacabaed7eb2 to your computer and use it in GitHub Desktop.
Show unread email count via IMAP.
This file contains hidden or 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/python | |
import imaplib | |
import sys | |
class MailHandler: | |
def CheckUnread(self, username, password): | |
imapConnection = imaplib.IMAP4_SSL('your.mailserver.com',993) | |
imapConnection.login (username, password) | |
imapConnection.select() | |
mailCount = len(imapConnection.search(None, 'UNSEEN')[1][0].split()) | |
if mailCount > 0: | |
print str(mailCount) + ' : ' + username | |
MyMail = MailHandler() | |
MyMail.CheckUnread('[email protected]','password') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment