#!/usr/bin/env python # -*- coding: utf8 -*- import smtplib from email.mime.text import MIMEText textfile='sendmail.html' with open(textfile, 'rb') as f: msg = MIMEText(fp.read(),'html','utf8') msg.set_charset('utf8') me = '[email protected]' you = '[email protected]' msg['Subject'] = 'The contents of %s,中文標題' % textfile msg['From'] = me msg['To'] = you s = smtplib.SMTP('mx3.qq.com') #s.login() try: ret = s.sendmail(me, [you], msg.as_string()) except smtplib.SMTPRecipientsRefused, e: print e s.quit()
python發送郵件
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.