EmailUtil.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:spider 作者: luanxiangming 项目源码 文件源码
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: ??????")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号