【发布时间】:2016-09-29 07:55:22
【问题描述】:
我想使用 Python 更改“收件人”和“发件人”字段的电子邮件地址。到目前为止,我做了以下工作以阅读必填字段。请任何人提出建议,如何对它们进行更改。
from email.parser import Parser
fp = open('2.eml', 'r+')
headers = Parser().parse(fp)
# Make changes only within a code, Not in to the file. I would like to save given changes for from in to my 2.eml file
headers.replace_header('from', 'newEmail@domain.com')
print ('To: %s' % headers['to'])
print ('From: %s' % headers['from'])
print ('Subject: %s' % headers['subject'])
【问题讨论】: