python實(shí)現(xiàn)的接收郵件功能示例【基于網(wǎng)易POP3服務(wù)器】
本文實(shí)例講述了python實(shí)現(xiàn)的接收郵件功能。分享給大家供大家參考,具體如下:
一 簡(jiǎn)介
本代碼實(shí)現(xiàn)從網(wǎng)易POP3服務(wù)器接收郵件
二 代碼
import poplib import re import tkinter class 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.entryPort.insert(tkinter.END,'110') self.entryPop.place(x=50,y=5) self.entryPort.place(x=50,y=30) self.entryUser.place(x=50,y=55) self.entryPass.place(x=50,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.user(user) pop.pass_(pw) stat=pop.stat() self.text.insert(tkinter.END,'Staus:%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') str_lines=[] for l in lines: str_lines.append(l.decode(encoding = 'utf-8')) self.text.insert(tkinter.END,"\n".join(filter(rx_headers.match,str_lines))) self.text.insert(tkinter.END,'\n') self.text.insert(tkinter.END,"-"*30+'\n') except Exception as e: self.text.insert(tkinter.END,'接收錯(cuò)誤\n') root =tkinter.Tk() window=Window(root) root.mainloop()
三 運(yùn)行結(jié)果
更多關(guān)于Python相關(guān)內(nèi)容可查看本站專題:《Python Socket編程技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進(jìn)階經(jīng)典教程》及《Python文件與目錄操作技巧匯總》
希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。
- python登錄pop3郵件服務(wù)器接收郵件的方法
- python發(fā)送郵件接收郵件示例分享
- Python實(shí)現(xiàn)發(fā)送與接收郵件的方法詳解
- 利用python發(fā)送和接收郵件
- Python接收Gmail新郵件并發(fā)送到gtalk的方法
- 在Python中使用poplib模塊收取郵件的教程
- 在Python的Flask框架下收發(fā)電子郵件的教程
- 簡(jiǎn)單實(shí)現(xiàn)python收發(fā)郵件功能
- Python使用smtp和pop簡(jiǎn)單收發(fā)郵件完整實(shí)例
- python smtplib模塊自動(dòng)收發(fā)郵件功能(一)
- python smtplib模塊自動(dòng)收發(fā)郵件功能(二)
- Python使用POP3和SMTP協(xié)議收發(fā)郵件的示例代碼
相關(guān)文章
python實(shí)現(xiàn)獲取單向鏈表倒數(shù)第k個(gè)結(jié)點(diǎn)的值示例
這篇文章主要介紹了python實(shí)現(xiàn)獲取單向鏈表倒數(shù)第k個(gè)結(jié)點(diǎn)的值,結(jié)合實(shí)例形式分析了Python針對(duì)單向鏈表的定義、遍歷、傳值、判斷等相關(guān)操作技巧,需要的朋友可以參考下2019-10-10Python中Numpy與TensorFlow版本兼容問(wèn)題完美解決辦法
這篇文章主要給大家介紹了關(guān)于Python中Numpy與TensorFlow版本兼容問(wèn)題的完美解決辦法,確保Python版本與TensorFlow版本兼容是首要任務(wù),因?yàn)椴患嫒莸慕M合可能導(dǎo)致導(dǎo)入錯(cuò)誤或其他運(yùn)行時(shí)問(wèn)題,需要的朋友可以參考下2024-07-07Python實(shí)現(xiàn)上課點(diǎn)名器系統(tǒng)
今天給大家分享一個(gè)讀者粉絲投稿的,關(guān)于上課點(diǎn)名的實(shí)戰(zhàn)案例,對(duì)Python上課點(diǎn)名器實(shí)現(xiàn)過(guò)程感興趣的朋友,一起來(lái)看看是如何實(shí)現(xiàn)的吧2021-10-10DRF跨域后端解決之django-cors-headers的使用
這篇文章主要介紹了DRF跨域后端解決之django-cors-headers的使用,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-01-01