我已经阅读了几个关于如何在Python中阅读电子邮件的答案。所有这些都部分工作,因为它无法正确处理从垃圾桶中恢复的消息或消息。因此,我的问题是:如何阅读标记为已读的邮件?在Python中有更强大的方法吗?这是我正在使用的代码:
import poplib
import email
mailServer = 'pop.gmail.com'
emailID = 'myemail'
emailPass = 'mypass'
myEmailConnection = poplib.POP3_SSL(mailServer)
myEmailConnection.user(emailID)
myEmailConnection.pass_(emailPass)
EmailInformation = myEmailConnection.stat()
numberOfMails = EmailInformation[0]
for i in range(numberOfMails):
print(myEmailConnection.retr(i+1)[1])