Deliverability

Mailgun emails going to spam? Check link tracking first

When the same message lands in spam via Mailgun but not HubSpot, the click-tracking redirect is one cause to test. Links get rewritten to a tracking domain that may not match your own. Turn click tracking off, or use a custom tracking domain on your sending domain, then confirm SPF, DKIM and DMARC pass.

Sohail HussainSohail Hussain10 min read

Short answer

  • Send the same message three times: click tracking on, click tracking off, and both tracking types off. If only the first lands in spam, turn click tracking off for that mail, or point a tracking hostname on your own domain at Mailgun and serve it over HTTPS.
  • If all three still go to spam, tracking isn't the cause. Check SPF, DKIM and DMARC alignment and blacklists next.

You see the same domain and the same From address landing in the inbox through HubSpot and in spam through Mailgun. One person who hit exactly this on a community forum traced it to Mailgun's click-tracking redirect, not the open pixel. That is one report, not a rule, so test it on your own mail before you change anything else.

Why it happens

With click tracking on, Mailgun rewrites each link in your message. As Mailgun's help center describes it, the links use a tracking hostname that is a CNAME pointing to mailgun.org. Links are rewritten with this tracking hostname. A click first goes to Mailgun, which returns a redirect to the original URL. A filter sees a message from your domain whose links all point to another hostname, and it can score both the mismatch and the reputation of that hostname.

Likely causes, most common first:

  1. Click tracking itself. Every link is wrapped, which is a bigger change to the message than a 1x1 open pixel.
  2. A tracking hostname with no CNAME or an inactive certificate. Mailgun's default hostname is email.{your-domain}, and the tracking hostname is configurable in the Mailgun application. If the CNAME is missing, tracked links can break or redirect wrongly.
  3. Plain http tracking links. Mailgun's default tracking scheme is http, and HTTPS is a setting you turn on.
  4. Weak authentication. SPF, DKIM or DMARC that passes but doesn't align with your From domain looks the same to a filter as a tracking problem.
  5. Recipient-side filtering. Other threads describe activation emails going to spam only for people behind corporate mail filters, and password resets failing while report emails from the same app arrive fine. The causes in those threads aren't established. Reset emails are short and link-heavy, so a tracking redirect around a long token URL is a plausible trigger, but that is a guess.

HubSpot sends from its own infrastructure with its own tracking setup. A different result doesn't make HubSpot better; it tells you something in the message path differs, and link tracking is one candidate.

Step-by-step fixes

Fix 1: confirm that click tracking is the trigger

  1. Pick two test mailboxes that currently receive your mail in spam (a Gmail and an Outlook address is a good minimum).
  2. Send version A: click tracking on, open tracking on.
  3. Send version B: click tracking off, open tracking on.
  4. Send version C: both off.
  5. Keep subject and body identical, and send each version several times. One result can be noise.

Reading the results: if only A goes to spam, click tracking is your cause. If B still spams and C reaches the inbox, the open pixel matters too. If all three spam, skip to Fix 4.

Fix 2: turn click tracking off

For transactional mail (activation links, password resets, receipts) you rarely need click data. A rewritten link in a security-sensitive message can also look suspicious to a person hovering over it. I'd turn it off there and keep it for marketing mail where you read the numbers.

Mailgun's help center explains that tracking headers and parameters take precedence over the global domain settings, which is useful for tracking only a specific group of messages (tracking headers have precedence over domain settings). So you can switch it off per message, and leave the domain default alone:

curl --user "api:YOUR_API_KEY" \
  https://api.mailgun.net/v3/mg.example.com/messages \
  -F from="App <noreply@mg.example.com>" \
  -F to="user@recipient.test" \
  -F subject="Reset your password" \
  -F text="..." \
  -F o:tracking-clicks=no \
  -F o:tracking-opens=no

If you send over SMTP, the equivalent is the X-Mailgun-Track-Clicks: no header. To change the domain default instead, go to Sending > Domain settings, pick the right domain, and use Edit in the Tracking section. Global tracking settings are on the domain details page of the control panel.

Split the mail streams

Send transactional mail from its own subdomain with tracking off by default, and marketing mail from another subdomain with tracking on. One stream's reputation then can't drag the other down.

Fix 3: put the tracking hostname on your own domain, and serve it over HTTPS

If you need click data, make sure links use a hostname on your sending domain and that it works.

  1. In Mailgun, open Sending > Domain settings > Tracking and note the Tracking hostname. The default is email.{domain}, and you can change it.
  2. At your DNS host, add a CNAME for that hostname. The tracking hostname should return mailgun.org for the US region, or eu.mailgun.org for the EU region.
  3. Don't put other records on the same hostname. Mailgun's DNS guides warn that any other records on a CNAME hostname are never seen. If your DNS provider already created an email record, use a different tracking hostname.
  4. Wait for DNS to propagate, then confirm with dig or nslookup that the hostname resolves to Mailgun.
  5. Switch the tracking protocol to HTTPS. In Mailgun's one-click flow, you go to Sending > Domain settings > Tracking, click Edit next to Tracking protocol, choose HTTPS and save. Mailgun then generates a Let's Encrypt certificate and switches your URLs from HTTP to HTTPS.
  6. Open a tracked link from a test email in a browser. It should load without a certificate warning and land on your real page.

Plan matters here. Mailgun's HTTPS tracking article says one-click HTTPS tracking is available on the Foundation, Scale, Contract and Enterprise plans. On other plans there is a manual route that needs a CDN, described in the same article. Check which applies to you in Mailgun's HTTPS tracking guide.

HSTS can break tracked links

If your root domain sends an HSTS header with includeSubDomains, browsers force HTTPS on the tracking hostname. Mailgun's click-tracking troubleshooting says this makes tracking links time out unless HTTPS tracking is set up.

Fix 4: check SPF, DKIM and DMARC alignment

Tracking often gets blamed when authentication is the real problem.

  1. Send a test to a Gmail address, open the message, choose Show original, and look for SPF: PASS, DKIM: PASS and DMARC: PASS.
  2. Confirm the passing domain matches your From domain (alignment), not only Mailgun's.
  3. Paste the headers into our email header analyzer if the raw text is hard to read.
  4. If DMARC is missing, publish a monitoring policy first:
DNS TXT Record
Type:TXT
Host:_dmarc
Value:v=DMARC1; p=none; rua=mailto:dmarc@example.com
  1. Tighten the policy only after you know every legitimate sender passes. The DMARC generator, SPF generator and DKIM generator build the records, and the SPF, DKIM and DMARC setup guide walks through them.
  2. Run your domain and sending IP through a blacklist checker such as MXToolbox. A listing changes the whole picture. See also our note on blacklists.

Which cause matches your symptom

CauseSymptomFix
Click rewritingSpam only with click tracking onTurn it off for that mail, or use your own tracking hostname
Missing tracking CNAMEBroken or odd redirectsAdd the CNAME, wait, re-verify
http tracking linksPlain http links, possible browser warningsEnable HTTPS tracking (plan permitting)
HSTS on your domainTracked links time outUse a domain without HSTS or set up HTTPS tracking
Misaligned authenticationSpam with tracking on and offFix SPF, DKIM, DMARC alignment
Corporate filterOnly one company's staff affectedAsk their IT to allowlist you

Checklist before you test again

  • Tracking CNAME resolves to mailgun.org (or eu.mailgun.org for EU).
  • No other DNS records on the tracking hostname.
  • Tracked links open without a certificate warning.
  • SPF, DKIM and DMARC pass and align in Gmail's Show original.
  • Domain and IP are not on a blacklist.
  • You changed one thing at a time between tests.

If nothing works

If tracking is off, authentication passes and you're still in spam, contact Mailgun support through your account's help center. If only one company's recipients are affected, ask that company's IT team for the rule that fired. Include the full headers of a spammed message, your sending domain, timestamps, the message ID, the affected recipient domains and the tests you ran.

Subject: Mail from {your-domain} lands in spam with Mailgun, not with another sender

Hello,

Messages sent through Mailgun from {your-domain} land in spam at {recipient domains}.
The same From address sent through another platform reaches the inbox.

What I tested (same subject and body):
- Click tracking on, open tracking on: spam
- Click tracking off, open tracking on: {result}
- Both off: {result}

SPF, DKIM and DMARC: pass and aligned (headers attached).
Tracking hostname: {tracking-hostname}, CNAME verified, protocol {http or https}.
Example message ID: {message-id}, sent {timestamp with timezone}.

Could you check the reputation of my sending IP and tracking domain on your side,
and tell me if anything on the account affects filtering?

Thanks,
{name}

Where Mailneo fits

Mailneo can't fix a Mailgun delivery problem. It can send through a Mailgun account you connect, and its click and open tracking can be switched off per campaign. Team admins can also set a custom tracking domain with a CNAME to t.mailneo.link, but as of November 2026 those links are served over plain http, not HTTPS, so weigh that first. Mailneo checks SPF, DKIM and DMARC for connected accounts, but it can't change your DNS or guarantee inbox placement.

Common questions

Does open tracking cause spam placement too?

It can, but the forum report behind this article found the click redirect was the trigger, not the pixel. Your three-way test (Fix 1) shows which applies to you.

Should I just turn all tracking off?

For transactional mail, usually yes. For marketing mail, keep tracking if you use the data, but fix the hostname, HTTPS and authentication first.

Why did HubSpot not have this problem?

HubSpot sends from different infrastructure with its own tracking setup, so the message path differs. That points to a difference worth testing, not to a fault in either platform.

Do I need DMARC if I turn tracking off?

Yes. A missing or misaligned DMARC record can send mail to spam on its own, and Gmail and Yahoo expect authenticated mail from bulk senders. See our email deliverability checklist.

deliverabilitymailgun
Share this article
Sohail Hussain

Sohail Hussain

Founder & CEO at Mailneo

Building Mailneo — AI-powered email marketing for growing businesses.

Related Articles

Deliverability

Apollo + Mailgun: "domain not on a Mailgun account" and IMAP

Apollo shows a "domain not being on a Mailgun account" error and asks for an IMAP host because Mailgun is a transactional sending service with no mailboxes. Verify the domain in Mailgun if you send by API; for sequences that need replies, connect a Gmail, Outlook or SMTP+IMAP mailbox instead.

Sohail Hussain|8 min read
Deliverability

Connection refused #111 on SMTP port 587: how to fix it

Connection refused #111 on port 587 means your server's TCP connection never reached the SMTP host, so a firewall, security group or hosting policy is blocking outbound traffic. Test the port with openssl s_client, open egress, switch to port 2525 or 465, or send through the provider's HTTP API instead.

Sohail Hussain|10 min read
Deliverability

DMARC Fails When SPF and DKIM Pass: Fix Alignment (550 5.7.23)

DMARC needs SPF or DKIM to pass and the passing domain to match your visible From domain. When both pass for a different domain (a vendor's bounce domain, a Mailgun subdomain), DMARC still fails. Sign DKIM with your From domain; one aligned DKIM signature is enough.

Sohail Hussain|9 min read
Deliverability

Fake Mailgun and SMTP2GO "payment information invalid" emails

An email claiming your Mailgun or SMTP2GO payment information is invalid, with a link to a lookalike domain such as smtp2go-support.sbs, is phishing. Don't click. Type the vendor's address yourself, check billing in your account, then report the message to the vendor and the domain's registrar.

Sohail Hussain|8 min read

Ready to supercharge your email marketing?

Start sending smarter emails with AI-powered campaigns. No credit card required.

Get Started Free