python 发送邮件 附件名为中文

构造附件

att = MIMEText(open(Filename, "rb").read(), "base64", "utf-8")
att["Content-Type"] = "application/octet-stream"
# 附件名称为中文时的写法
att.add_header("Content-Disposition", "attachment", filename=("gbk", "", "5.3版本接口详细测试结果.html"))
msg.attach(att)

你可能感兴趣的:(python 发送邮件 附件名为中文)