Email headers showing unknown sender when using Mailgun API

I’m having trouble with email delivery through Mailgun in my Laravel app. When I check the email headers, I see this weird issue:

Received: from <unknown> (<unknown> []) by api-n01.prod.eu-central-1.postgun.com with HTTP id XXXXXXXXXXXXXXXXX; Mon, 28 Feb 2022 02:08:33 GMT

But then further down the headers look fine:

From: "Company Name" <[email protected]>

I’m not doing anything special with my setup. Just basic Mailgun configuration. The problem is some email servers are rejecting my messages because of that unknown part in the received header.

My config looks normal:

'sender' => [
    'email' => env('MAIL_SENDER_ADDRESS', '[email protected]'),
    'title' => env('MAIL_SENDER_NAME', 'Sample App'),
],

This sender info works perfectly. But I can’t figure out why the received header shows unknown instead of proper server details. Do I need to set something else in the mail configuration? Is there a way to fix this unknown issue?

This happens because Mailgun’s API doesn’t work like regular mail servers - there’s no actual SMTP connection happening. When you use their HTTP API, no server hostname or IP gets negotiated during the SMTP handshake, so you get those unknown values in the headers. Your rejection issue is probably strict SPF or DKIM policies on the receiving end. Check that your domain’s SPF record includes Mailgun’s servers - add “include:mailgun.org” to your DNS. Also make sure DKIM signing is set up correctly in your Mailgun dashboard. I had the same deliverability problems until I switched to Mailgun’s SMTP relay instead of their HTTP API. The SMTP method creates proper received headers with real server info. Just change your Laravel mail driver to smtp and use Mailgun’s SMTP credentials instead of their API key. Fixed the unknown header issue completely for me.

this isn’t really a mailgun issue - most email providers show weird headers when you use their apis. i’ve seen the same thing with sendgrid. the real problem is probably your domain reputation. if it’s new or you’re sending low volume, that’s what’s triggering spam filters, not the headers.

The unknown server info in Mailgun’s received headers is actually quite normal. Their HTTP API operates differently from traditional SMTP servers, resulting in placeholder values due to the lack of a genuine server-to-server connection. This shouldn’t lead legitimate email servers to reject your messages as long as your authentication is properly configured. I faced similar delivery issues and discovered that the root cause was incomplete domain verification on Mailgun’s side. Ensure that you’ve included all necessary DNS records—like MX, TXT for domain verification, and CNAME for tracking. Additionally, verify that your sending domain is fully authorized within your Mailgun account settings. It’s the authentication records that primarily affect deliverability, rather than those received headers showing unknown values. If you’re still encountering rejections, examine the bounce logs in Mailgun’s dashboard for specific error messages from the receiving servers.