I am working on a project that involves use of a transactional email service (like sendgrid). My question is can we create a CNAME in our domain DNS (i.e. smtp.example.com or client1.example.com) that refers to the email service smtp server?

This will mask the SMTP server of the service (i.e. sendgrid, mailgun) we use.

Our goal is to vary the DNS entry depending on our client. As an example, we might have client1.example.com, client2.example.com, etc. Each client subdomain would be a CNAME to the email service. We could also switch email services just by changing where the CNAME refers if needed. As an example:

    NAME                    TYPE   VALUE
client1.example.com        CNAME  smtp.emailservice.com
client2.example.com        CNAME  smtp.emailservice.com

In doing research on this it appears to work, but I wanted to see if there were any issues that I should look for. We are not dealing with MX records, POP3, or any incoming emails at all, nor can we use an API for sending. It has to go through SMTP.

Thank you!

  • This is quite confusing. Can you edit your question to make it a bit more clear what you're trying to achieve, and the problems you faced when you tried it?
    – Tim
    Mar 10 '16 at 19:46
  • Are you trying to 'round robin' the DNS for your smtp?
    – Citizen
    Mar 10 '16 at 19:55
  • @Tim - I'm not sure how to edit the question to be more clear, but perhaps my other response to will help.
    – vbuser2004
    Mar 13 '16 at 16:36
  • @Citizen - no, I am not trying to create a round robin. The purpose is to mask the SMTP provider from the client to streamline management. In creating these DNS entries on my domain the management of the customer will be easier. Plus, if we need to change SMTP services in the future we need only change our DNS and not update every client.
    – vbuser2004
    Mar 13 '16 at 16:41

The naive answer to your question is a simple "yes". You obviously can create CNAME RRs in the suggested fashion. Which problems may arise thereof, is an entirely different matter - CNAMES are commonly misunderstood and the usage is prone to errors.

Main points to consider are:

  • you must not use your CNAMEs as destinations for MX RRs (RFC 2181 section 10.3)
  • you must not create any other RR type definitions for the labels you are defining as CNAMEs (STD 13, RFC 1034, section 3.6.2)

So, taking the RR definitions from your question as a prerequisite, the following cases would present invalid use:

; these are INVALID RR definitions, don't even try!
mail.example.com.     IN MX  client1.mydomain.com. ; no MX to CNAME RRs
client1.mydomain.com. IN A        ; no other RR types for CNAMEd labels

In future posts, when using IP addresses and name spaces for example and / or documentation purposes, consider sticking to the definitions of IPv4 Address Blocks reserved for Documentation (RFC 5737) and Special-Use Domain Names (RFC 6761) to avoid confusion.

  • I updated the DNS entries to conform with RFC 6761 with the exception of the email service as it made the sample less clear. If you can suggest a better way to write this I would be happy to edit. Txs!
    – vbuser2004
    Mar 13 '16 at 16:46

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.