I’m working with MailGun’s Go SDK and running into an issue where my emails show up with the ‘on behalf of’ prefix in the sender field. Right now when I send emails, the from address displays like this:
[email protected] on behalf of Jane Doe <[email protected]>
But I want it to appear as just:
Jane Doe <[email protected]>
I’ve already configured SPF and DKIM records following MailGun’s documentation and they’re validating correctly. I’m also using SetDKIM(true) in my Go code when creating the message. Despite this setup, the ‘on behalf of’ text still appears. What configuration am I missing to make the sender address display cleanly without this prefix? Do I need additional DNS records or API settings?
Had this exact problem with MailGun - drove me nuts for weeks! Your sending domain and From domain need to match up properly. You’re sending through mail.mydomain.com but saying it’s from example.com, so email clients think it might be spoofed. SPF and DKIM aren’t enough - you need a DMARC policy for the From domain that explicitly allows your MailGun sending domain. Without DMARC alignment, Gmail and Outlook will show that annoying ‘on behalf of’ text as a security thing. I fixed it by switching my From addresses to subdomains of my verified sending domain. The authentication has to match at the organizational level or you’ll keep seeing this.
The ‘on behalf of’ issue is usually a DMARC alignment problem, not SPF/DKIM. Even with those set up correctly, email clients still show that prefix when domain alignment fails. You’re sending from mail.mydomain.com but using [email protected] as the From address - that’s your mismatch right there. Two ways to fix this: Use a From address that matches your sending domain, like [email protected] or configure DMARC records for example.com to authorize mail.mydomain.com as a sender. Most email clients check DMARC alignment to decide whether to show that ‘on behalf of’ text.
You’re probably missing the DMARC record completely. Had the same issue - Mailgun’s docs don’t emphasize this enough. You need a DMARC policy on the from domain (example.com), not just the sending domain. Add a basic DMARC record like v=DMARC1; p=none; sp=none; to example.com’s DNS first, then tighten it up once emails start flowing.
This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.