31

I'd like to use Mailgun to send e-mails from a web application, sending newsletters as well as transactional mails.

I set up a sudomain "subdomain.domain.tld" and configured the DNS as specified on the Mailgun panel, except for the (optional) MX record needed to recieve mail at that subdomain. This is because the current hoster/domain-registrar doesn't allow setting an MX record for subdomains, just for the main domain. Their support says something like 'We don't care about this, deal with it.'.

I don't want to configure the main domain for the use by Mailgun, as the client is recieving regular e-mail the main domain that is handled by other servers.

The current setup allows me to send mail using mailgun with the "From"-address "mail@domain.tld" to most major E-Mail providers including Gmail, Yahoo and Hotmail. However the mails get rejected by some providers (e.g. mail.ru, freenet.de or arcor.de), with an error messages like the following:

<bounce+gibberish-user@=provider@subdomain.domain.tld>: Sender address rejected: Domain not found

Other providers have slightly different messages, but point to the same problem:

  • Domain of sender address [..] does not exist.
  • Unrouteable mail domain, verifying bounce failed
  • Unroutable sender address

It seems to me that the mails get rejected because of the missing MX record for subdomain.domain.tld , as used within the bounce address.

How do I solve this problem without moving the complete domain to another registrar that allows me to change MX records for subdomains? I would really like to avoid this.

Is it possible to configure mailgun to use different bounce addresses that are actually valid independent of my MX records? For example bounce-gibberish-mydomain-tld@mailgun.com instead of bounce-gibberish@mydomain.tld?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
theister
  • 903
  • 1
  • 8
  • 9

3 Answers3

23

Three possible solutions, in order of preference:

  1. Find a different DNS provider, that will allow you to put an MX on a subdomain. Note that this does not necessarily require you to change registrars.

  2. Use your base domain with mailgun, perhaps utilizing their forwarding feature to send incoming mails to whoever hosts your mailboxes.

  3. Use someone other than mailgun, that will allow the bounce address to be set to their domain instead of yours.

Joe Sniderman
  • 434
  • 3
  • 6
  • Thank you. As I feared, there doesn't seem to be an easy solution. I wonder, where on a scale from "painless" to "pain-in-the-*ss" is the process of switching DNS providers? Are existing entries copied automatically? Might there be downtime involved? – theister Jan 18 '15 at 20:08
  • 2
    Generally speaking, you would first copy the entries yourself, and then and only then, change nameservers. This is not something that happens automatically, it is something you need to do. As long as you set up the records on the new nameservers first, you should not have any downtime. – Joe Sniderman Jan 19 '15 at 13:31
  • for me the easiest way was to use the base domain instead of using a subdomain – timaschew Oct 19 '16 at 22:21
  • Interesting article for Digital Ocean case here : http://moandjiezana.com/blog/2016/mailgun-on-digital-ocean/ – Miguel Bocquier Dec 10 '16 at 17:19
  • Workaround for Dreamhost MX record on subdomain: https://discussion.dreamhost.com/t/mx-records-for-non-hosted-subdomain/56246 – Adrian Carr Apr 23 '18 at 17:35
4

My setup:

  • root MX set up for gmail. Sends and receives as @mydomain.com
  • added mailgun and delivers as @mg.mydomain.com
  • getting bounces when doing mailgun sends to certain email providers (e.g. sbcglobal.net) because as mailgun said, don't add MX record if I already have another email service set up to use MX records.

My fix:

  • Contacted godaddy support. They told me I could add more MX records for my subdomain. Instead of MX @ mxa.mailgun , it's MX mg mxa.mailgun

Hope this helps.

theNotSoPro
  • 308
  • 3
  • 16
1

I ran into the same issue. In my case I'm using Office 365 for receiving emails and Mailgun to send emails. Here is my DNS config for my Mailgun subdomain mg.{name}.com which solved the problem:

email               IN CNAME   mailgun.org.
email.mg            IN CNAME   mailgun.org.
mg                  IN CNAME   mailgun.org.
@                   IN MX 0    {name}-com.mail.protection.outlook.com.
@                   IN MX 10   mxb.mailgun.org.
@                   IN MX 10   mxa.mailgun.org.
@                   IN TXT     "v=spf1 include:spf.protection.outlook.com include:mailgun.org ~all"
krs._domainkey.mg   IN TXT     "k=rsa; p={insert the value from mailgun here}"

One very important thing, is that you can't have two SPF lines in your config. I had to merge these two lines...

@    IN TXT "v=spf1 include:spf.protection.outlook.com -all"
@    IN TXT "v=spf1 include:mailgun.org ~all"

into one...

@    IN TXT "v=spf1 include:spf.protection.outlook.com include:mailgun.org ~all"
emcoding
  • 772
  • 11
  • 22
  • Does it matter if you have 2 spf lines for different subdomains?? For instance, i have on in a line for a subdomain `mailer` and another in the root. Is that an issue? – Askdesigners Jan 30 '18 at 14:43
  • Sorry, for my late response. In my case it does matter, maybe it depends on the DNS provider itself. – emcoding Feb 04 '18 at 14:41
  • 1
    It doesn't make sense to have your MX records pointing to both outlook and mailgun. This could route your incoming mail incorrectly – Phil Sep 08 '20 at 17:18