5

I want to be able to send email to any subdomain I like and not have to configure A records and MX records for each subdomain. Ideally I could send an email to test@a.domain.com and test@z.domain.com and not have to configure anything other than my original domain.com.

My current setup:

I have a domain (domain.com) and want to have multiple subdomains. (a.domain.com, b.domain.com, c.domain.com, etc).

I have an MX record setup to point to domain.com and all email works fine for that domain. I have NOT setup A records for all the subdomains (and really don't want to).

Steve Sloka
  • 260
  • 2
  • 8

3 Answers3

5

If you have no other resource records of any kind for the subdomains, then a wildcard record will work just fine. This assumes that the subdomains don't need different A records from one another, or maybe no A records at all - is this the case?

You can either set just the wildcard MX record, as well as an A record if you need it..

*    IN    MX    15    your.mail.server.example.com.
*    IN    A     192.0.2.15

..or else create a wildcard CNAME record pointing to the root, if it already has the correct entries.

*    IN    CNAME    @
Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • I'm getting this when I try and send email: Relay access denied [RCPT_TO] – Steve Sloka Mar 30 '12 at 12:57
  • What server is giving you that error - the server in your `MX` record, or a different relay that you're using? – Shane Madden Mar 30 '12 at 14:51
  • If I try and send an email to the subdomain (e.g. test@sub.example.com), my email server responds with that error code. If I setup an A record, all works well. – Steve Sloka Mar 30 '12 at 14:57
  • What software is your email server running, and what configuration have you done on it? – Shane Madden Mar 30 '12 at 14:58
  • Sorry I missed typed the last one, I get the error from the server which I'm sending from. So if I send from a gmail or yahoo account the gmail / yahoo servers send me that msg. In practice, I'm trying to use SendGrid's PareAPI and not use an email server at all. Their instructions just need me to point to mx.sendgrid.net and that's all. I then receive the email via HTTP Post to a URL in my application. – Steve Sloka Mar 30 '12 at 15:26
  • I ended up switching my DNS to dnsimple.com and was able to setup a WildCard entry for my MX record. I am able to send to and subdomain and it hits the same server. – Steve Sloka Apr 23 '12 at 21:02
1

I think you're going to need to set up an A records for each sub-domain, with the same IP address of your main domain. I don't believe their is a workaround in your scenario.

Henry
  • 910
  • 1
  • 5
  • 17
0

This should work as you described automatically if you have correctly set up MX records for the top level domain.com (and it is an A record) and your subdomains are CNAMEs pointing to this A record. CNAMEs are re-written to the A record they point at by compliant mailservers (canonicalised) as they are explicitly banned in the RFC (see section 5.2.2):

http://www.ietf.org/rfc/rfc1123.txt

Dan Bernstein's quick and easy overview here:

http://cr.yp.to/im/cname.html

I had an issue at work where a client had misconfigured their DNS to have www.website.com as the A record and website.com as a CNAME. They then didn't understand why emails weren't being delivered to them. The mail servers were canonicalising the fred@website.com into fred@www.website.com. You can switch this behaviour off but then you aren't complying with the RFC then.

webtoe
  • 1,946
  • 11
  • 12
  • Thanks, but my goal is to not setup A records for all the subdomains. – Steve Sloka Mar 30 '12 at 12:58
  • That's my point. You don't. You set up an A record for the top level (domain.com) and it will be applied to subdomains for the purpose of email. Mail server software will use the records for domain.com for your subdomains (z.domain.com; which are done using CNAMES) as they are canoncalised to the A record. – webtoe Apr 02 '12 at 10:44
  • I've tried that and I get the following when sending email to test: Relay access denied [RCPT_TO] – Steve Sloka Apr 02 '12 at 18:57
  • That sounds like a general mail configuration issue. The mail server isn't accepting your mail probably because you haven't authenticated with it to prove that you're allowed to set mail through it. – webtoe Apr 03 '12 at 09:31