Script and README

This commit is contained in:
Joshua Sherman 2014-01-14 22:31:15 -05:00
parent 886e19ac7c
commit c07a3220cc
2 changed files with 23 additions and 0 deletions

15
gmail-unread.py Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env python3
from __future__ import print_function
import imaplib
import os
email = os.environ['EMAIL']
password = os.popen('security find-generic-password -w -s email -a "' + email + '"').read().replace('\n', '')
imap = imaplib.IMAP4_SSL('imap.gmail.com', '993')
imap.login(email, password)
imap.select()
fp = open('/tmp/GMAIL_UNREAD', 'w')
print(len(imap.search(None,'UnSeen')[1][0].split()), file=fp)