使用MailGun发送邮件时,如何删除“代表”的内容?

huangapple go评论81阅读模式
英文:

Removing 'on behalf of' when sending mail using MailGun

问题

我正在尝试弄清楚如何在不以“代表”的方式发送邮件,使用MailGun Golang API。

目前,发件人地址的格式如下(其中foo.com是发件人的电子邮件域,bar.com是我的域):

john=foo.com@mail.bar.com 代表 John Smith <john@foo.com>

我需要做什么才能使其显示为以下格式:

John Smith <john@foo.com>

我已按照MailGun的说明设置了SPF和DKIM,并且一切都通过了正确性验证。在发送邮件时,我还使用了SetDKIM(true)。是否有我遗漏的设置或需要进行的其他验证?

英文:

I'm trying to figure out how to send mails using the MailGun Golang API without having it sent 'on behalf of'.

This is how the From address currently looks (where foo.com is the sender's email domain and bar.com is my domain):

john=foo.com@mail.bar.com on behalf of John Smith &lt;john@foo.com&gt;

What do I need to do so that it looks like this instead:

John Smith &lt;john@foo.com&gt;

I've set up SPF and DKIM according to the MailGun instructions and everything passes as being correct. I've also used SetDKIM(true) when I'm sending out the mail. Is there some setting I'm missing or additional validation I need to do?

答案1

得分: 26

你需要在电子邮件头中将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都通过了。然后我注意到发件人头部与发件人地址不同,而Outlook会关注这一点,而Gmail和Thunderbird则不太关心。

尝试将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 &lt;emailname@example.com&gt;

Sender设置为Sender: Persons Name &lt;emailname@example.com&gt;

英文:

You need to set the sender property in the email header to the from address as well most likely.

I had this same problem using NodeMailer for a node.js project. Gmail and Thunderbird would show the from address fine but Outlook would show the from address as

emailname=example.com@mail.example.com on behalf of emailname@example.com

When I looked into the full email message header I saw that the sender: in the header was emailname=example.com@mail.example.com and the from: was emailname@example.com

we looked into the spf and dkim records at first thinking it was an issue there but they were fine and in the email header it even said spf and dkim both were passing so then i noticed the sender header was different than the from and Outlook pays attention to that where gmail and thunderbird don't care as much.

Try setting the sender header to the from value.

Here is a sample of part of one of the wrong email headers edited to match example above

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 &lt;emailname@example.com&gt;

make Sender equal to Sender: Persons Name &lt;emailname@example.com&gt;

答案2

得分: 23

添加到Dhodgin的答案中:

如果您在MailGun中使用子域名(例如mail.bar.com),并且发件人电子邮件地址使用不同的域名(例如john@foo.com),则会出现“代表”的消息。
要解决此问题,请添加一个自定义的MIME头“sender”,并将其设置为与发件人电子邮件地址相同。

要使用MailGun API添加自定义头,请确保添加h:前缀,例如:

request.AddParameter("h:sender", "John Smith <john@foo.com>");
英文:

To add to Dhodgin's answer:<br/><br/>
The on behalf of message comes up if you're using a subdomain in MailGun such as mail.bar.com and the from email address is using a different domain such as john@foo.com<br/>
To fix this issue add a custom MIME header "sender" and set it to be the same as the from email address.<br/><br/>
To add a custom header using the <a href="https://documentation.mailgun.com/en/latest/api-sending.html#sending"> MailGun api</a> make sure to add a h: prefix such as:

request.AddParameter(&quot;h:sender&quot;, &quot;John Smith &lt;john@foo.com&gt; &quot;);

答案3

得分: 18

你是否添加了一个mg子域名?

如果你添加了一个子域名,比如@mg.domain.com,那么请确保你从name@mg.domain.com发送邮件

我之前也遇到了同样的问题,因为我没有意识到我想要的发件人地址是name@domain.com,但是我按照建议给mailgun添加了一个子域名mg.domain.com。

所以当我尝试从name@domain.com发送邮件时,会显示"代表"或"发送自",但是一旦我使用了子域名name@mg.domain.com,"代表"的消息就消失了...我真是太蠢了...

英文:

Have you added an mg sub domain?

If you have added a sub-domain such as @mg.domain.com then make sure you send your emails from name@mg.domain.com

I had the same problem, as I didn't realize that I wanted to have the sender address name@domain.com but I had added - as recommended - a subdomain to mailgun: mg.domain.com.

So when I tried to send an email from name@domain.com I got "on behalf of" / "sent by" but as soon as I've used the subdomain name@mg.domain.com - the "on behalf" message is gone... stupid me...

答案4

得分: 3

你是否尝试从与你设置SPF/DKIM的域名不同的域名发送邮件?

你只能从你在Mailgun上授权的域名发送白标签邮件。

英文:

Are you trying to send from a different domain than the one you setup SPF/DKIM on?

You can only send white-labelled emails from the domain you're authorized with Mailgun.

答案5

得分: 0

对于在Mailgun子域中使用SMTP的用户,请设置“From”和“Sender”参数。例如:

message["From"] = 'John Smith <john@foo.com>'
message["Sender"] = 'john@foo.com'
英文:

For those using SMTP in mailgun subdomain. Set the "From" and "Sender" parameter. eg

message[&quot;From&quot;] = &#39;John Smith &lt;john@foo.com&gt;&#39;
message[&quot;Sender&quot;] = &#39;john@foo.com&#39;

huangapple
  • 本文由 发表于 2015年2月9日 09:50:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/28401673.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定