Python 发送HTML格式的邮件
以下代码是可以发送HTML格式的邮件
import smtplib from email.mime.text import MIMEText _user = "yy@qq.com" _pwd = "授权码" # _to = "ft_clover@163.com" _recer=["aa@qq.com","bb@163.com",] mess = """python 邮件发送测试
""" msg=MIMEText(mess,'html','utf-8') msg["Subject"] = " don't panic" msg["From"] = _user msg["To"] = ",".join(_recer)#区别与给一个人发,指定某个人用 msg["To"] = _to 多个人用.join try: s=smtplib.SMTP_SSL("smtp.qq.com",465) s.login(_user,_pwd) s.sendmail(_user,_recer,msg.as_string()) s.quit() print("Success!") except smtplib.SMTPException as e: print("Failed,%s"%e)