gmail/mymail scripts updated
This commit is contained in:
parent
bd6aaeccdd
commit
d54799aece
|
@ -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("?")
|
||||
|
|
|
@ -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("?")
|
||||
|
|
Loading…
Reference in New Issue