def send_email(format, subject, content, attach=None):
# ??????????????????????????? utf-8 ????
msg = MIMEText(content, format, auth.mail_info["mail_encoding"])
msg["Subject"] = Header(subject, auth.mail_info["mail_encoding"])
msg["from"] = auth.mail_info["from"]
msg["to"] = auth.mail_info["to"]
# if attach:
# with open(attach, "rb") as f:
# part = MIMEApplication(f.read(), Name=basename(attach))
# msg.attach(part)
try:
smtpobj.sendmail(auth.mail_info["from"], auth.mail_info["to"], msg.as_string())
smtpobj.quit()
print("??????")
except smtplib.SMTPException:
print("Error: ??????")
评论列表
文章目录