我需要构建一个应用程序,它在从交换服务器读取正文(和附件)后简单地转发电子邮件。该应用程序是在云中构建并用 python 编码的,所以我们认为我们会使用 exchangelib。
我的目标是转发电子邮件,以最大限度地减少由于云架构的出口流量。
从 exchangelib源代码(从第 778 行开始)我找到以下代码:
def create_forward(self, subject, body, to_recipients, cc_recipients=None, bcc_recipients=None):
if not self.account:
raise ValueError('%s must have an account' % self.__class__.__name__)
if not self.id:
raise ValueError('%s must have an ID' % self.__class__.__name__)
return ForwardItem(
account=self.account,
reference_item_id=ReferenceItemId(id=self.id, changekey=self.changekey),
subject=subject,
new_body=body,
to_recipients=to_recipients,
cc_recipients=cc_recipients,
bcc_recipients=bcc_recipients,
)
def forward(self, subject, body, to_recipients, cc_recipients=None, bcc_recipients=None):
self.create_forward(
subject,
body,
to_recipients,
cc_recipients,
bcc_recipients,
).send()
我希望当我使用电子邮件(之前下载的)作为自己调用转发时,转发的消息从服务器而不是来自调用者获取有效负载。
希望我的问题很清楚...
提前致谢