我按照https://developers.google.com/gmail/api/v1/reference/users/messages/send#examples
通过Gmail API在Python中发送电子邮件我有一个域名别名和收件箱设置,包含catch-all地址,因此发送到anything@sub.example.com和anything@alias.example.com的电子邮件最终都会发送到tech@sub.example.com的收件箱中。
tech@sub.example.com和tech@alias.example.com都设置为"我拥有的帐户"在Gmail设置中,我添加它时无需验证第二个帐户的所有权(可能是因为其域名是别名)。
使用API我处理收到的电子邮件,然后从发送到的帐户重新发送电子邮件,设置"来自" MIMEMessage中的标题。不幸的是,他们总是从拥有邮箱的电子邮件地址收到。
其他问题(例如[1],[2])表明这应该"只是工作",至少通过SMTP,我也尝试过。我认为一定是使用域别名的怪癖。
[1] Changing the `from` address when sending an email through GMail
[2] How to set From Address to any email other gmail in ( Sending Email in .NET Through Gmail )?