【脚本语言系列】关于Python邮件服务poplib,你需要知道的事
来源:互联网 发布:警惕网络陷阱 编辑:程序博客网 时间:2024/05/19 01:10
如何使用poplib
使用poplib接收QQ邮件
注意:使用第三方邮件客户端,需要使用短信开通并获取授权码。
http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
# -*- coding:utf-8 -*-#import reimport poplibimport Tkinterclass Window: def __init__(self, root): label1 = Tkinter.Label(root, text = 'POP3') label2 = Tkinter.Label(root, text = 'Port') label3 = Tkinter.Label(root, text = '用户名') label4 = Tkinter.Label(root, text = '密码') label1.place(x = 5, y = 5) label2.place(x = 5, y = 30) label3.place(x = 5, y = 55) label4.place(x = 5, y = 80) self.entryPOP = Tkinter.Entry(root) self.entryPort = Tkinter.Entry(root) self.entryUser = Tkinter.Entry(root) self.entryPass = Tkinter.Entry(root, show='*') self.entryPOP.insert(Tkinter.END, "pop.qq.com") self.entryPort.insert(Tkinter.END, "995") self.entryUser.insert(Tkinter.END, "********@qq.com")# ******@qq.com为测试邮箱,下同 self.entryPass = Tkinter.Entry(root, show='*') self.entryPass.insert(Tkinter.END, "****************") # 填入“授权码” self.entryPOP.place(x = 40, y = 5) self.entryPort.place(x = 40, y = 30) self.entryUser.place(x = 40, y = 55) self.entryPass.place(x = 40, y = 80) self.get=Tkinter.Button(root, text = '收取邮件', command = self.Get) self.get.place(x=60, y=120) self.text = Tkinter.Text(root) self.text.place(y=150) def Get(self): try: host = self.entryPOP.get() port = int(self.entryPort.get()) user = self.entryUser.get() pw = self.entryPass.get() # pop = poplib.POP3(host) pop = poplib.POP3_SSL(host, port) pop.set_debuglevel(1) pop.user(user) pop.pass_(pw) stat = pop.stat() self.text.insert(Tkinter.END,'Status: %d message(s), %d bytes\n' % stat) rx_headers = re.compile(r"^(From|To|Subject)") for n in range(stat[0]): response, lines, bytes = pop.top(n+1, 10) self.text.insert(Tkinter.END,"Message %d (%d bytes)\n" % (n+1, bytes)) self.text.insert(Tkinter.END, "-" * 30 + '\n') self.text.insert(Tkinter.END, "\n".join(filter(rx_headers.match, lines))) self.text.insert(Tkinter.END, "\n") self.text.insert(Tkinter.END, "-" * 30 + "\n") except: self.text.insert(Tkinter.END, '接收错误\n')root = Tkinter.Tk()window = Window(root)root.minsize(600, 480)root.mainloop()
1. 客户端界面
2. 交互信息
3. 收信信息
什么是poplib
Python中poplib模块提供了对POP3协议的支持。
使用POP3协议可以登录E-mail收取邮件。
0 0
- 【脚本语言系列】关于Python邮件服务poplib,你需要知道的事
- 【脚本语言系列】关于Python邮件服务smtplib,你需要知道的事
- 【脚本语言系列】关于Python系统管理,你需要知道的事
- 【脚本语言系列】关于Python容器,你需要知道的事
- 【脚本语言系列】关于Python网页服务Microsoft IIS,你需要知道的事
- 【脚本语言系列】关于Python网页服务Apache,你需要知道的事
- 【脚本语言系列】关于Python网页服务Zope, 你需要知道的事
- 【脚本语言系列】关于Python网页服务Plone,你需要知道的事
- 【脚本语言系列】关于PythonWeb服务自动化BeautifulSoup,你需要知道的事
- 【脚本语言系列】关于PythonWeb服务自动化webbrowser模块,你需要知道的事
- 【脚本语言系列】关于PythonWeb服务自动化REST,你需要知道的事
- 【脚本语言系列】关于PythonWeb服务自动化Web API,你需要知道的事
- 【脚本语言系列】关于Python调试报错,你需要知道的事
- 【脚本语言系列】关于Python开发环境搭建,你需要知道的事
- 【脚本语言系列】关于Python数值计算NumPy, 你需要知道的事
- 【脚本语言系列】关于Python测试工具lettuce, 你需要知道的事
- 【脚本语言系列】关于Python测试工具mock, 你需要知道的事
- 【脚本语言系列】关于Python测试工具unittest, 你需要知道的事
- maven关于jsp页面加载图片和css路径的问题
- 远程连接服务器无法上传文件
- 我勒个草二
- 兼容ie 7/8/9/10 ajax兼容360兼容模式
- hadoop2.7.2学习笔记05-hadoop文件系统API定义-hadoop文件系统类org.apache.hadoop.fs.FileSystem
- 【脚本语言系列】关于Python邮件服务poplib,你需要知道的事
- [RK3288][Android6.0] 调试笔记 --- 移除uboot和kernel开机logo
- 动起来->nativescript + angular
- 威纶weinview EB8000软件
- 图像语义分割数据集
- activemq的几种基本通信方式总结
- [Leetcode] 143. Reorder List 解题报告
- 使用android studio开发系统级app的gradle配置
- Linux命令- systemctl