您的位置:首页 > 编程语言 > Python开发

python一个发邮件的函数

2015-12-09 15:43 639 查看
from  datetime import date,timedelta
from email.mime.text import MIMEText

def mailto(rec_list,mail_content):
sender=-.com'
smtpserver='.com'
user='guanzhongkai'
passwd=''
content = file(mail_content ).read()
msg=MIMEText(content,'plain')
msg['From']=sender
msg['Subject']="PV last week of Mobile-BU"
msg['To']=",".join(rec_list)
smtp=smtplib.SMTP()
smtp.connect('','')
smtp.starttls()
#    smtp.set_debuglevel(1)
smtp.login(user,passwd)
smtp.sendmail(sender,rec_list,msg.as_string())
smtp.quit()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: