Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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).

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

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    @
share|improve this answer
    
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
show 1 more comment

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.

share|improve this answer
    
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 2 '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 2 '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 3 '12 at 9:31
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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