我正在使用此代码以 10 秒的延迟检查新邮件。
import poplib
from email import parser
import time
def seeit():
pop_conn = poplib.POP3_SSL('pop.gmail.com')
pop_conn.user('xxx')
pop_conn.pass_('xx')
#Get messages from server:
messages = [pop_conn.retr(i) for i in range(1, len(pop_conn.list()[1]) + 1)]
# Concat message pieces:a
messages = ["\n".join(mssg[1]) for mssg in messages]
#Parse message intom an email object:
messages = [parser.Parser().parsestr(mssg) for mssg in messages]
for message in messages:
print message['subject']
pop_conn.quit()
starttime=time.time()
while True:
k=10.0
print "tick"
seeit()
time.sleep(k - ((time.time() - starttime) % k))
如何检索没有标题的电子邮件正文?