gmail/mymail scripts updated
This commit is contained in:
parent
bd6aaeccdd
commit
d54799aece
|
@ -4,15 +4,13 @@
|
||||||
|
|
||||||
import imaplib
|
import imaplib
|
||||||
|
|
||||||
#default imap port is 993, change otherwise
|
try:
|
||||||
M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
|
from credentials import gmail_login,gmail_password
|
||||||
from credentials import gmail_login,gmail_password
|
M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
|
||||||
M.login(gmail_login,gmail_password)
|
M.login(gmail_login,gmail_password)
|
||||||
|
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
|
||||||
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
|
unread = counts[0].split()[4][:-1]
|
||||||
|
M.logout()
|
||||||
unread = counts[0].split()[4][:-1]
|
print(int(unread))
|
||||||
|
except:
|
||||||
print(int(unread))
|
print("?")
|
||||||
|
|
||||||
M.logout()
|
|
||||||
|
|
|
@ -16,17 +16,18 @@ def IMAP_starttls(self, keyfile=None, certfile=None,cert_reqs=ssl.CERT_NONE,ca_c
|
||||||
imaplib.IMAP4.__dict__['starttls']=IMAP_starttls
|
imaplib.IMAP4.__dict__['starttls']=IMAP_starttls
|
||||||
imaplib.Commands['STARTTLS']=('NONAUTH',)
|
imaplib.Commands['STARTTLS']=('NONAUTH',)
|
||||||
|
|
||||||
# read credentials
|
try:
|
||||||
from credentials import mymail_server,mymail_port,mymail_login,mymail_password
|
# read credentials
|
||||||
|
from credentials import mymail_server,mymail_port,mymail_login,mymail_password
|
||||||
|
|
||||||
M=imaplib.IMAP4(mymail_server, mymail_port)
|
M=imaplib.IMAP4(mymail_server, mymail_port)
|
||||||
M.starttls()
|
M.starttls()
|
||||||
M.login(mymail_login,mymail_password)
|
M.login(mymail_login,mymail_password)
|
||||||
|
|
||||||
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
|
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
|
||||||
|
|
||||||
unread = counts[0].split()[4][:-1]
|
unread = counts[0].split()[4][:-1]
|
||||||
|
M.logout()
|
||||||
print(int(unread))
|
print(int(unread))
|
||||||
|
except:
|
||||||
M.logout()
|
print("?")
|
||||||
|
|
Loading…
Reference in New Issue