Python “错误”;uid";使用imaplib进行搜索时
我在开发python应用程序时遇到了一个奇怪的问题 应用程序应该解析邮件收件箱中的未读邮件,获取特定邮件,处理邮件正文并将其存储到数据库中 对于我域中的前7封邮件,一切似乎都很正常,但对于最后一封和4封@Gmail,结果与预期不符,存储到数据库中的邮件不是正确的,事实上,它们正是正确邮件之后的第4封邮件 我正在展示我开发的代码,不要对我太苛刻,我是一种新的编码: main.pyPython “错误”;uid";使用imaplib进行搜索时,python,email,imaplib,Python,Email,Imaplib,我在开发python应用程序时遇到了一个奇怪的问题 应用程序应该解析邮件收件箱中的未读邮件,获取特定邮件,处理邮件正文并将其存储到数据库中 对于我域中的前7封邮件,一切似乎都很正常,但对于最后一封和4封@Gmail,结果与预期不符,存储到数据库中的邮件不是正确的,事实上,它们正是正确邮件之后的第4封邮件 我正在展示我开发的代码,不要对我太苛刻,我是一种新的编码: main.py from src_pckg import reader reader.read("***@m***p.com", "
from src_pckg import reader
reader.read("***@m***p.com", "***", "imap.***.com", 993, "noreply@s***d.com")
reader.py
def read(username, password, host, port, sender_of_interest):
#Con details
imap_con = imaplib.IMAP4_SSL(host, port)
imap_con.login(username, password)
imap_con.select("INBOX")
#Print all unread messages from a certain sender
status, response = imap_con.search(None, 'UNSEEN', '(FROM "%s")' % (sender_of_interest))
unread_msg_nums = response[0].split()
print(len(unread_msg_nums))
for e_id in unread_msg_nums:
status, data = imap_con.uid('fetch', e_id, '(RFC822)')
msg = data[0][1].decode(encoding='UTF-8')
if re.search("has given you a gift subscription", msg):
#Process the mail
return True