博客
关于我
python接收邮件_Python POP3协议收取邮件方法
阅读量:95 次
发布时间:2019-02-26

本文共 1552 字,大约阅读时间需要 5 分钟。

POP3?????????????????Python???poplib?????????????POP3?????????????????Python???POP3???????????

POP3????

POP3?Post Office Protocol - Version 3?????????????3??????????????????????????????????????????????POP3?????????????????????POP3????????????????POP3??????????????

Python?????????

1. ??????

?????????poplib?????Python???????POP3???????

import poplib

2. ???POP3?????

????????????POP3?????????????your pop3 server name???????POP3???????????????POP3?????????995?

emailServer = poplib.POP3('your pop3 server name')

3. ??POP3???

????POP3??????????????????????????????

emailServer.user('your mail account')emailServer.pass_('your mail password')

4. ??????

????????????????POP3????????????1??????????????????????????

emailServer.set_debuglevel(1)

5. ?????????

??????POP3?????????????????????????????????????

serverWelcome = emailServer.getwelcome()print(serverWelcome)

6. ????????

POP3?????????????????????????????????????

emailMsgNum, emailSize = emailServer.stat()print(f'????? {emailMsgNum}???????? {emailSize}')

7. ??????

????????????????????????retr???????????i+1????????????1??????

for i in range(emailMsgNum):    for piece in emailServer.retr(i + 1)[1:]:        if piece.startswith('Subject'):            print(f'\t{piece}')            break

8. ????

???????????POP3???????

emailServer.quit()

????

  • ??????????????????POP3???????????
  • ????????????????POP3????????
  • ????????????1??????????????????
  • ????????????????????????????????????????
  • ??????

    ???POP3???????????????????Python????????????????????

    ????????????????????????????

    转载地址:http://qejk.baihongyu.com/

    你可能感兴趣的文章
    Python 接口自动化 —— requests框架
    查看>>
    python 接口自动化数据结构(如列表、字典、元组)
    查看>>
    Python 接口自动化测试中的深拷贝与浅拷贝~
    查看>>
    Python 接口自动化测试中的高阶函数
    查看>>
    python 控制 cmd 命令行颜色
    查看>>
    Python 操作 Azure Blob Storage
    查看>>
    Python 操作 Excel 全攻略 | 包括读取、写入、表格操作、图像输出和字体设置
    查看>>
    Python 操作 JMeter 探索:pymeter 实操指南
    查看>>
    Python 操作 Redis
    查看>>
    Python 操作Mysql(PyMysql)
    查看>>
    Python 操作Redis
    查看>>
    Python 操作sqlite数据库及保存查询numpy类型数据(一)
    查看>>
    Python 操作sqlite数据库及保存查询numpy类型数据(二)
    查看>>
    Python 操作数据库
    查看>>
    Python 数据分析与可视化实战
    查看>>
    python 数据可视化 -- matplotlib02
    查看>>
    python 数据可视化利器
    查看>>
    Python 数据可视化详解
    查看>>
    python 数据库查询返回list或tuple
    查看>>
    Python 数据库连接池管理的基本知识 (附Demo)
    查看>>