12

Mailgun is telling me to set up a TXT record for mg.mydomain.com with a value of v=spf1 ... plus a CNAME record for email.mg.mydomain.com with value mailgun.org.

I did that, and mailgun verified my domain no problem. The issue is when I send emails, certain receiving mail servers are rejecting my emails with message "Sender address rejected: Domain not found". I'm pretty sure this is because "mg.mydomain.com" doesn't exist -- I don't have a CNAME for it. However, I can't create a CNAME for it because it's already used for the TXT record.

So now I don't know what to do. Can I put this v=spf1 thing in a different TXT record so that I can free up the mg. CNAME, so that sender-verification will work on these picky servers?

mpen
  • 272,448
  • 266
  • 850
  • 1,236

1 Answers1

14

It appears the missing ingredient is an A record for mg.mydomain.com

A

mg.mydomain.com.  A  nnn.nnn.nnn.nnn:

If email.mg.mydomain.com CNAME is in the same DNS zone as mydomain.com, mg.mydomain.com, etc. and there's an A record with the ip pointing back to the hostname then setting up the CNAME, TXT, and MX records should be straightforward:

CNAME

email.mg.mydomain.com.  CNAME   mailgun.org.

TXT

mydomain.com.   TXT  v=spf1 a include:mailgun.org ~all

(optional for receiving)

MX

mydomain.com.   MX  mxa.mailgun.org.
mydomain.com.   MX  mxb.mailgun.org.
l'L'l
  • 44,951
  • 10
  • 95
  • 146
  • 1
    Aha! I didn't think about using an `A` record. This DNS stuff is still kind of new to me, but I looked it up. That makes sense. They really should add that to their list of things to configure. Thank you! – mpen Oct 24 '15 at 02:41
  • 2
    You're welcome! I agree that if they don't mention that in the documentation they definitely should :) – l'L'l Oct 24 '15 at 02:47
  • 3
    Which IP Address should be used in A record? – Sagar Mahajan Jan 22 '16 at 13:14
  • @SagarMahajan: It should be the IP that points to your mailserver/hostname. – l'L'l Jan 22 '16 at 17:31
  • 10
    To be explicit: Go to [your domains](https://mailgun.com/app/domains) on Mailgun, click on mydomain.com, and you should see an IP address listed under "Domain Information". This is what the A record for mg.mydomain.com should be set to. (Mailgun should include this in their documentation...) – user20061 Jun 15 '16 at 04:19
  • Thanks for the tips @user20061. Mailgun still doesn't recognize that I set my CNAME correctly in CloudFlare. In CF, I have `CNAME email.mg is an alias of mailgun.org`. But https://app.mailgun.com/app/domains/mg.mydomain.com always says "None found" for `CNAME email.mg.mydomain.com`. Any ideas? Thanks. – Ryan Jan 01 '19 at 02:11