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)