Day29 发送带附件邮件的示例代码缺少 email.attach(attachment)
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 92/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- documentation
Research direction
Open Day21-30/29.Python发送邮件和短信.md and find the “发送带附件的邮件” example. Read the attachment-building block, then ensure the example attaches the created attachment to the email message. Done means the documented example includes the attachment and accurately sends it with the message.
Written by the indexing model from the issue text.
Description
在 Day21-30/29.Python发送邮件和短信.md 中,「发送带附件的邮件」一节的示例代码存在一个小问题:
代码虽然创建了 attachment 对象并设置了相关头部信息,但没有调用 email.attach(attachment) 将附件添加到邮件主体中。这会导致实际发送的邮件不包含附件。
问题代码位置:
Python
with open(f'resources/王大锤离职证明.docx', 'rb') as file:
attachment = MIMEText(file.read(), 'base64', 'utf-8')
attachment['content-type'] = 'application/octet-stream'
filename = quote('王大锤离职证明.docx')
attachment['content-disposition'] = f'attachment; filename="{filename}"'
此处缺少 email.attach(attachment)
建议修复:
在 with 代码块结束后(或内部末尾)添加:
Python
email.attach(attachment)
感谢作者和维护团队的辛勤付出,这个项目帮助了很多初学者!
- Dominant language
- Jupyter Notebook
- Stars
- 187k
- Forks
- 55.8k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jackfrued/Python-100-Days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jackfrued/Python-100-Days#1203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
jackfrued/Python-100-Days#1200 · 2 comments ·
-
Day81部分文本表述模糊/有误 Open
Difficulty 1/5 Under an hour Newbie friendliness 78/100
jackfrued/Python-100-Days#1192 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jackfrued/Python-100-Days#1186 ·
-
Day21 文件读写示例代码存在问题 Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
jackfrued/Python-100-Days#1172 ·
All issues in jackfrued/Python-100-Days
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·