gmail/mymail scripts updated

This commit is contained in:
Kolan Sh 2014-08-15 09:28:31 +04:00
parent bd6aaeccdd
commit d54799aece
2 changed files with 22 additions and 23 deletions

View File

@ -4,15 +4,13 @@
import imaplib
#default imap port is 993, change otherwise
M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
try:
from credentials import gmail_login,gmail_password
M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
M.login(gmail_login,gmail_password)
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
unread = counts[0].split()[4][:-1]
print(int(unread))
M.logout()
print(int(unread))
except:
print("?")

View File

@ -16,6 +16,7 @@ def IMAP_starttls(self, keyfile=None, certfile=None,cert_reqs=ssl.CERT_NONE,ca_c
imaplib.IMAP4.__dict__['starttls']=IMAP_starttls
imaplib.Commands['STARTTLS']=('NONAUTH',)
try:
# read credentials
from credentials import mymail_server,mymail_port,mymail_login,mymail_password
@ -26,7 +27,7 @@ M.login(mymail_login,mymail_password)
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
unread = counts[0].split()[4][:-1]
print(int(unread))
M.logout()
print(int(unread))
except:
print("?")