python - 使用 smtplib 发送电子邮件时附件重复
问题描述
我正在使用 smtplib 从 csv 发送电子邮件,并尝试将 pdf 附加到每封电子邮件。但是,我最终每封电子邮件都有两个附件;有人可以帮我确定该附件在哪里被调用了两次吗?
# Attach the pdf to the msg going by e-mail
with open(EMAIL_FILE, "rb") as f:
attach = MIMEApplication(f.read(),_subtype="pdf")
attach.add_header('Content-Disposition','attachment',filename=str(EMAIL_FILE))
msg.attach(attach)
mail.sendmail(EMAIL_FROM, EMAIL_TO, msg.as_string())
解决方案
推荐阅读
- java - 如何使用枚举序数 queryDSL 创建查询
- python - socket.send 和 socket.sendall() 的区别
- twitter-bootstrap - Vue少加载css“无法读取未定义的属性'分母'”
- c# - 如何使用 C# 将 CSV 文件转换为 Parquet
- html - 使用 Nginx 在 Linux 中的静态文件
- mysql - 在 Centos7 上启动时出现 MySQL 5.7 错误
- javascript - 如何避免在 for 循环完成之前调用 .map 函数?
- c++ - 数组只是一个包含许多数据的变量吗?
- python - 正则表达式查找列中有多少单词以元音开头并且有超过 5 个字母
- php - post_meta 值上的 WordPress OrderBY