python smtp发送邮件

来源:互联网 发布:淘宝购买数据分析 编辑:程序博客网 时间:2024/06/02 17:40

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()


0 0
原创粉丝点击