Search code examples
phpemaildnswebserver

DNS issue with wildcard subdomain and mail server


Hi I have bought a domain name, lets say example.com and I needed to set a wildcard subdomain on the DNS in order to each user of the website to have his own subdomain. I have created an email account on the server, lets say cutopus@cutop.us in order to let users contact the staff of the website.

Now, If I send email from the server using sendmail with contact@example.com as sender address, for example, the email delivers correctly, but If I want to send an email to cutopus@cutop.us the email does not get delivered.

My DNS records are as follows:

A           @               51.255.108.205    Automatic
A      mail.cutop.us        51.255.108.205    Automatic
CNAME      *                cutop.us       Automatic

MX    cutop.us              mail.cutop.us       10      Automatic

Using the following command:

dig cutop.us

I get the following output:

; <<>> DiG 9.8.3-P1 <<>> cutop.us
;; global options: +cmd
;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41051
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;cutop.us.          IN  A

;; ANSWER SECTION:
cutop.us.       1798    IN  A   51.255.108.205

;; Query time: 483 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri May  6 11:04:30 2016
;; MSG SIZE  rcvd: 42

And using the following command:

dig MX cutop.us

I get the following output:

; <<>> DiG 9.8.3-P1 <<>> MX example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61642
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;cutop.us.          IN  MX

;; AUTHORITY SECTION:
cutop.us.       1799    IN  SOA dns1.registrar-servers.com. hostmaster.registrar-servers.com. 2016050501 43200 3600 604800 3601
;; Query time: 486 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri May  6 11:06:43 2016
;; MSG SIZE  rcvd: 99

Now the question is, why I cannot send emails to cutopus@cutop.us


Solution

  • The reason that you cannot email bob@example.com is that you only have an MX record configured for the address bob@cut.op.example.com in order to have mail delivered to example.com you need to have an MX record of

    MX    @     mail.cutop.us       10
    

    unfortunately you will then have an issue with the rules of DNS, which forbid a CNAME record where another record exists.

    If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different. This rule also insures that a cached CNAME can be used without checking with an authoritative server for other RR types.

    Basically you can't have a Wildcard record and an MX record at the same level.