Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing 'on behalf of' when sending mail using MailGun

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):

[email protected] on behalf of John Smith <[email protected]> 

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

John Smith <[email protected]> 

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?

like image 290
Bill Avatar asked Feb 09 '15 01:02

Bill


People also ask

How do I stop an email from sending on behalf of?

Right-click on your address within the 'From' field and select Remove from the drop-down menu. Enter the address you have permissions to 'send as' or 'send on behalf' of.

How do I remove the sent on behalf of header?

The “sent on behalf of” text in your message header can be removed by setting up DKIM for your sending domain. This will make the heading of your messages appear a little cleaner and only your own From email address will be displayed (the name of our mail server will not be displayed).

Why do my emails say on behalf of?

What "On Behalf Of" Signifies. Ultimately, the "On Behalf Of" notation highlights the mismatch between the domain used in the Sender field (mail.example.com) and the domain used in the From field (example.com).


2 Answers

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

[email protected] on behalf of [email protected] 

When I looked into the full email message header I saw that the sender: in the header was [email protected] and the from: was [email protected]

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 [email protected];        spf=pass (google.com..... Sender: [email protected] From: Persons Name <[email protected]> 

make Sender equal to Sender: Persons Name <[email protected]>

like image 97
Dhodgin Avatar answered Sep 23 '22 22:09

Dhodgin


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 [email protected]
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 <[email protected]> "); 
like image 30
Julian Avatar answered Sep 25 '22 22:09

Julian