我想弄清楚如何使用Mailgan 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>

我已经按照邮枪的指示设置了SPF和DKIM,一切都是正确的.我发邮件时也用了SetDKIM(true).我是否缺少一些设置或需要进行额外的验证?

推荐答案

您需要将邮箱标题中的sender属性设置为发件人地址.

对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不太关心的地方.

try 将sender标头设置为from值.

以下是为匹配上述示例而编辑的其中一个错误邮箱头的部分示例

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>

Go相关问答推荐

Pulumi-S3-当策略依赖于访问点时,如何将AccesspintPolicy附加到访问点

更改位置级别和时间戳零点Golang

Golang XML密钥名称冲突

如何使用工作区方法扩展克隆的Golang库

我找不到pcap.Openlive的设备名称

什么东西逃到了堆里?

可以';t从主机连接到ScyllaDB容器

无法使用exec从管道中读取.Go中的命令

我应该先解锁然后再广播吗?

Golang和Gin web框架在router.Run()之后执行代码

如何判断范围内的字段?

Gorm 预加载给出了模糊的列错误

通过 golang 中的 gremlin-go 库嵌入 gremlin 服务器

在 Gorm 的 AfterFind() 钩子中获取智能 Select struct 的值

如何将具有嵌入式 struct 的 struct 展平为 json

使用反射在 struct 内迭代切片 struct

Scanner.Buffer - 最大值对自定义拆分没有影响?

Golang 泛型同时具有接口和实现

Golang LinkedList 删除第一个元素

Go 错误:cannot use generic type without instantiation