email.py

import smtplib
import email
from email.mime.text import MIMEText
mail_host = "smtp.163.com"
mail_to = ["2245312214@qq.com"]
mail_user = "m18744115924@163.com"
mail_pwd = "********"

msg = MIMEText("<html><h1>哈哈哈哈。。</h1>",'html','utf8')
msg['Subject'] = '大王给你发邮件啦!'
msg['From'] = mail_user
msg['To'] = ";".join(mail_to)

try:
    s = smtplib.SMTP()
    s.connect(mail_host,25)
    s.login(mail_user,mail_pwd)
    s.sendmail(mail_user,mail_to,msg.as_string())
    s.close()

except Exception as e:
    print(e)

 

posted @ 2016-10-10 10:08  JessisLong  阅读(96)  评论(0编辑  收藏  举报