Removing 'on behalf of' when sending mail using MailGun

五迷三道 提交于 2019-12-02 19:10:01

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 <emailname@example.com>

make Sender equal to Sender: Persons Name <emailname@example.com>

kapale

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...

To add to Dhodgin's answer:

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
To fix this issue add a custom MIME header "sender" and set it to be the same as the from email address.

To add a custom header using the MailGun api make sure to add a h: prefix such as:

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

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.

 /*The answer for your question is the "Sender="*/
 FILENAME HTMMAIL  EMAIL "userid@comain"                            
 SUBJECT="Testing sending e-mail from the mainframe"
 CONTENT_TYPE='TEXT/HTML'                              
 TO="target_userid@domain"                              
 FROM="sending_userid@domain" 
 SENDER="sending_userid@domain"; 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!