Let's say I want to start a service where customers get their own subdomain on my domain for email addresses only.

I have an A record for mydomain.com and a CNAME for www.mydomain.com

If I add a wildcard MX record for *.mydomain.com, my understanding is that any email coming to my domain will route to the associated mailserver, except for www because CNAME's cannot overlap with MX records.

So email addresses such as

  • foo@mydomain.com
  • foo@customer1.mydomain.com
  • foo@bar.customer1.mydomain.com
  • foo@customer2.mydomain.com

Should all work correctly.

  • foo@www.mydomain.com

Will NOT work correctly.

Then, in my SMTP mailserver, I can parse the domain out of the email address, and route the message appropriately. Is there anything wrong with this plan?

  • Name MTA/SMTP mail server you would like to if you want to avoid nasty surprises. – AnFi Apr 22 '15 at 20:18

It's not completely clear what your overall plan entails but here are some clarifications about how wildcard records work in general. I think this should clarify what may potentially be a problem.

Wildcard records do not cover the base name (ie *.example.com. does not cover example.com.).

Wildcard records never overlap with anything, whether CNAME or any other record types.

From the wildcard section of RFC1034:

Wildcard RRs do not apply:


  • When the query name or a name between the wildcard domain and the query name is know to exist. For example, if a wildcard RR has an owner name of "*.X", and the zone also contains RRs attached to B.X, the wildcards would apply to queries for name Z.X (presuming there is no explicit information for Z.X), but not to B.X, A.B.X, or X.

(emphasis added)

Other than the above, which may or may not be a problem for what you had in mind, are you sure you actually want any random names that people out on the Internet come up with to have MX records (eg <obscenityofchoice>.example.com and whatnot)?


Wildcard DNS RRs are not really a very good answer to any known problem, and they are an especially bad idea for MX records as it is often difficult or even impossible to correctly configure any mail server to work properly with them.

Just be specific about exactly which domains you wish to use for email and configure the DNS and mail server(s) for them appropriately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.