亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

如何利用python發(fā)送郵件

瀏覽:2日期:2022-07-10 08:00:04

一、zmial發(fā)送郵件

zmial是第三方庫(kù),需進(jìn)行安裝

pip install zmail

完成后,來(lái)給發(fā)一封郵件

subject:標(biāo)題content_text:內(nèi)容

import zmail server = zmail.server(’發(fā)件人郵箱地址’,’授權(quán)碼’) server.send_mail(’收件人郵箱地址’,{’subject’:’Hello!’,’content_text’:’By zmail.’})

二、smtplib發(fā)送郵件

import smtplibfrom email.mime.text import MIMEText#--------發(fā)件相關(guān)參數(shù)--------smtpserver='smtp.qq.com' #連接服務(wù)器port = 465 #端口sender = '[email protected]'#賬號(hào)psw = 'xxxxx'#密碼 授權(quán)碼receiver='[email protected]'#接收人#--------編輯郵件內(nèi)容--------subject='qq郵件主題'body= ’<p>這個(gè)是發(fā)送的qq郵件</p>’msg = MIMEText(body,’html’,’utf-8’)msg[’from’]=sendermsg[’to’]=’[email protected]’msg[’subject’]=subject#-----------test_email-------smtp = smtplib.SMTP_SSL(smtpserver,port)#連接服務(wù)器smtp.login(sender,psw)#登錄smtp.sendmail(sender,receiver,msg.as_string())#發(fā)送郵件smtp.quit()

三、發(fā)送帶附件的郵件

import smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartimport ossmtpserver=’smtp.qq.com’port =465sender=’[email protected]’psw = ’xxxx’recevier = '[email protected]'filenamepath = os.path.join(os.path.dirname(os.path.realpath(__file__)),’ceshi.html’)with open(filenamepath,’rb’) as f: mail_body=f.read().decode(’utf-8’)msg = MIMEMultipart()msg[’from’]=sender#發(fā)件人msg[’to’]=recevier#收件人msg[’subject’]=’這是我的主題99’#主題# 正文body = MIMEText(mail_body,’html’,’utf-8’)msg.attach(body)#附件att = MIMEText(mail_body,’base64’,’gbk’)#用utf-8會(huì)出現(xiàn)亂碼att[’Content-Type’]=’application/octet-stream’att[’Content-Disposition’]=’attachment;filename='test_report.html'’msg.attach(att)####發(fā)送郵件try: smtp = smtplib.SMTP() smtp.connect(smtpserver)#連接服務(wù)器 smtp.login(sender,psw)#登錄except: smtp = smtplib.SMTP_SSL(smtpserver,port) smtp.login(sender,psw)#登錄smtp.sendmail(sender,recevier,msg.as_string())#發(fā)送郵件smtp.quit()

以上就是如何利用python發(fā)送郵件的詳細(xì)內(nèi)容,更多關(guān)于python 發(fā)送郵件的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 久草水蜜桃 | 啪一啪在线 | 久久婷婷五夜综合色频 | 外国黄色毛片 | 国产成人精品第一区二区 | 在线成人天天鲁夜啪视频 | 制服丝袜手机在线 | 亚洲最新 | 中文字幕小明 | 二级特黄绝大片免费视频大片 | 国产成年女人免费视频播放a | 1024你懂的国产 | 青青草a国产免费观看 | 色片免费在线观看 | 国产成人精品午夜 | 国产大战女模特在线视频 | 国产精品久久久久久久久免费观看 | 亚洲午夜精品专区国产 | 黄视频免费在线看 | 毛片啪啪啪 | 国产成人精品亚洲日本在线观看 | 久久精品影视 | 欧美一级aa天码毛片 | 本道久久综合88全国最大色 | 亚洲精品国产精品精 | 九九精品视频在线观看九九 | 99爱在线视频这里只有精品 | 97国产精品欧美一区二区三区 | 日韩一区二区三 | 999精品| 免费在线看黄网站 | a国产视频| 亚洲综合色区图片区 | 黄片123| 日韩欧美亚洲一区二区综合 | 毛片免费观看 | 尤物视频www| 国产永久在线视频 | 国产精品宅男在线观看 | 劲爆欧美色欧美 | 日韩亚洲一区中文字幕在线 |