This is where I am at, but I'm not sure where to go from here:
import imaplib
import email
conn = imaplib.IMAP4()
conn.login("username", "password")
status, messages = conn.select('INBOX')
if status != "OK":
print ("Incorrect mail box")
exit()
print (messages)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…