国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

python發(fā)送郵件

2019-11-14 16:58:19
字體:
供稿:網(wǎng)友
 1 # -*- coding: UTF-8 -*- 2 ''' 3 發(fā)送txt文本郵件 4 http://www.survivalescaperooms.com/liu-ke 5 ''' 6 import smtplib   7 from email.mime.text import MIMEText   8 mailto_list=['***@**.***']  9 mail_host="smtp.****.com"  #設(shè)置服務(wù)器10 mail_user="***@**.**"    #用戶名11 mail_pass="********"   #口令 12 mail_postfix="***.com"  #發(fā)件箱的后綴13   14 def send_mail(to_list,sub,content):  15     me="hello"+"<"+mail_user+"@"+mail_postfix+">"  16     msg = MIMEText(content,_subtype='plain',_charset='gb2312')  17     msg['Subject'] = sub  18     msg['From'] = me  19     msg['To'] = ";".join(to_list)  20     try:  21         server = smtplib.SMTP()  22         server.connect(mail_host)  23         server.login(mail_user,mail_pass)  24         server.sendmail(me, to_list, msg.as_string())  25         server.close()  26         return True  27     except Exception, e:  28         PRint str(e)  29         return False  30 if __name__ == '__main__':  31     if send_mail(mailto_list,"hello","hello world!"):  32         print "發(fā)送成功"  33     else:  34         print "發(fā)送失敗"

 

 

 1 # -*- coding: utf-8 -*- 2 ''' 3 發(fā)送html文本郵件 4 http://www.survivalescaperooms.com/liu-ke 5 ''' 6 import smtplib   7 from email.mime.text import MIMEText   8 mailto_list=["*****"]  9 mail_host="smtp.***.com"  #設(shè)置服務(wù)器10 mail_user="****"    #用戶名11 mail_pass="****"   #口令 12 mail_postfix="***.com"  #發(fā)件箱的后綴13   14 def send_mail(to_list,sub,content):  #to_list:收件人;sub:主題;content:郵件內(nèi)容15     me="hello"+"<"+mail_user+"@"+mail_postfix+">"   #這里的hello可以任意設(shè)置,收到信后,將按照設(shè)置顯示16     msg = MIMEText(content,_subtype='html',_charset='gb2312')    #創(chuàng)建一個實例,這里設(shè)置為html格式郵件17     msg['Subject'] = sub    #設(shè)置主題18     msg['From'] = me  19     msg['To'] = ";".join(to_list)  20     try:  21         s = smtplib.SMTP()  22         s.connect(mail_host)  #連接smtp服務(wù)器23         s.login(mail_user,mail_pass)  #登陸服務(wù)器24         s.sendmail(me, to_list, msg.as_string())  #發(fā)送郵件25         s.close()  26         return True  27     except Exception, e:  28         print str(e)  29         return False  30 if __name__ == '__main__':  31     if send_mail(mailto_list,"hello","<a href='http://www.survivalescaperooms.com/xiaowuyi'>小五義</a>"):  32         print "發(fā)送成功" ,mailto_list 33     else:  34         print "發(fā)送失敗"

 


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 环江| 顺平县| 宁化县| 海伦市| 乐安县| 南陵县| 北京市| 信阳市| 顺平县| 交口县| 克东县| 松潘县| 会东县| 高雄县| 山西省| 玉龙| 界首市| 南昌市| 霍林郭勒市| 廉江市| 张家口市| 达拉特旗| 睢宁县| 沅陵县| 宣城市| 普定县| 天柱县| 正蓝旗| 夏邑县| 乌恰县| 顺义区| 和平县| 利辛县| 舞钢市| 剑河县| 平果县| 房山区| 富民县| 阿拉尔市| 工布江达县| 呼玛县|