python回复邮件,如何使用Python imaplib回复电子邮件并包含原始邮件?

本文介绍如何使用Python的imaplib和email库回复电子邮件,同时包含原始邮件内容但不带附件。首先,通过遍历MIME消息部分,替换所有附件为纯文本占位符。然后,创建回复消息,包括纯文本和HTML版本的回复正文,并添加必要的邮件头信息。最后,将原始MIME消息对象附加到新邮件中并通过SMTP发送。
摘要由CSDN通过智能技术生成

I'm currently using imaplib to fetch email messages from a server and process the contents and attachments.

I'd like to reply to the messages with a status/error message and links to the resulting generated content on my site if they can be processed. This should include the original message but should drop any attachments (which will be large) and preferably replace them with just their filenames/sizes.

Since I'm already walking the MIME message parts, I'm assuming what I need to do is build a new MIME message tree containing a copy of the original message and delete/replace the attachment nodes.

Before I start down that path, I was hoping someone can give me some tips. Is there any kind of library function to do this? Any kind of standard behavior I should stick to?

I currently know of/am using the imaplib, smtplib and email modules and but may have mis

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值