使用Python显示电子邮件的完整原始源代码

2024-03-29 12:24:53 发布

您现在位置:Python中文网/ 问答频道 /正文

关于Reading the mail content of an mbox file using python mailbox的主要答案 显示如何显示.mbox文件中的电子邮件内容:

if message.is_multipart():
    content = ''.join(part.get_payload(decode=True) for part in message.get_payload())
else:
    content = message.get_payload(decode=True)

但是,这并不显示电子邮件的“完整原始来源”;我的意思是,当点击“显示原始邮件”时,我们几乎可以在所有网络邮件中看到:

Delivered-To: ...
Return-Path: ...
...

如何使用Python获取此信息mailbox

enter image description here


Tags: ofthetruemessageget电子邮件邮件mail