我试图弄清楚如何使用MailGun Golang API发送邮件而又不“代表”发送邮件。
这是当前发件人地址的外观(其中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
属性设置为最可能的发件人地址。
使用NodeMailer进行node.js项目时,我遇到了同样的问题。 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记录时认为这是一个问题,但它们很好,并且在电子邮件 header 中甚至表示spf和dkim都已通过,因此我注意到发件人 header 不同于from和Outlook注意到gmail和thunderbird不在乎的地方。
尝试将
sender
header 设置为from
值。这是部分错误的电子邮件 header 之一的示例,该 header 已编辑为与上述示例匹配
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/