鱼C论坛

 找回密码
 立即注册
查看: 2790|回复: 1

[原创] 读取邮件怎么才可以不重复读取

[复制链接]
发表于 2017-9-12 21:34:22 | 显示全部楼层 |阅读模式
1鱼币
读取邮件怎么才可以不重复读取,备注:因为不确定那个邮箱没办法删除邮件 ,但是每次连接都会重复读取,求助!
附代码:
def main() :
    email = 'xxxxx@163.com'
    password = 'xxxx'
    pop3_server = 'pop.163.com'
    p=poplib.POP3_SSL(pop3_server, port = 995)
    try:
        p.user(email)
        p.pass_(password)
    except poplib.error_proto as e:
        print("hehe")
    else:
        visit_all_listings(p)
    finally:
        p.quit
   # print("测试")
#显示邮件数目和大小
def visit_all_listings(p) :
    respons ,listings ,octets = p.list()
    for listing in listings:
        visit_listing(p,listing)
#读取没封的几个链接信息
def visit_listing(p,listing):
    number ,size = listing.decode('ascii').split()
    print("邮件 %s 有 %s byte" %(number,size))
    response,lines,octets =p.top(number,0)
    document = '\n'.join(line.decode('ascii') for line in lines)
    print("aaa1")
    message =email.message_from_string(document)
    print("aaa")
    for header in 'From' , 'TO' ,'Subject' ,'Date':
        if header in  message:
            print(header +':',message[header])
if __name__ == '__main__':
    main()

评分

参与人数 1荣誉 +1 鱼币 +1 收起 理由
purplenight + 1 + 1 好!

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-9-29 17:44:20 | 显示全部楼层
再给每封邮件一个属性(是否已读)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 21:04

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表