我试图弄清楚如何使用 MailGun Golang API 发送邮件,而不是“代表”发送邮件。
这是 From 地址当前的样子(其中 foo.com 是发件人的电子邮件域,bar.com 是我的域):
john=foo.com@mail.bar.com on behalf of John Smith <john@foo.com>
我需要做什么才能让它看起来像这样:
John Smith <john@foo.com>
我已经根据 MailGun 的说明设置了 SPF 和 DKIM,并且一切正常。我在发送邮件时也使用了 SetDKIM(true)
。我是否缺少某些设置或需要进行其他验证?
最佳答案
您需要设置sender
电子邮件 header 中的属性也很可能指向发件人地址。
我在 node.js 项目中使用 NodeMailer 时遇到了同样的问题。 Gmail 和 Thunderbird 会正常显示发件人地址,但 Outlook 会将发件人地址显示为
emailname=example.com@mail.example.com on behalf of emailname@example.com
当我查看完整的电子邮件标题时,我看到 sender:
在标题中是 emailname=example.com@mail.example.com
和 from:
是 emailname@example.com
我们起初查看了 spf 和 dkim 记录,认为这是一个问题,但它们很好,在电子邮件标题中甚至说 spf 和 dkim 都通过了,所以我注意到发件人标题与 from 和Outlook 会关注 gmail 和 Thunderbird 不太关心的地方。
尝试设置 sender
from
的标题值(value)。
这里是一个错误的电子邮件标题的一部分,它被编辑以匹配上面的示例
Received-SPF: pass (google.com....
Authentication-Results: mx.google.com;
dkim=pass header.i=@mail.example.com;
spf=pass (google.com.....
Sender: emailname=example.com@mail.example.com
From: Persons Name <emailname@example.com>
制作 Sender
等于 Sender: Persons Name <emailname@example.com>
关于email - 使用 MailGun 发送邮件时删除 'on behalf of',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28401673/