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

python smtp发送邮件

2015-09-29 12:28 549 查看
http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386832745198026a685614e7462fb57dbf733cc9f3ad000

def send_mail(receiver, subject, body):
print "send mail: ", subject
sender = 'xxx@abc.com'

m = MIMEMultipart()
m['to'] = receiver
m['from'] = sender
m['subject'] = subject
m.attach(MIMEText(body, 'html', 'utf-8'))
#print m.as_string()

s = smtplib.SMTP()
s.connect()
s.sendmail(sender, [receiver], m.as_string())
s.close()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: