Setting up root domain correctly for email + website

I’m new to setting up DNS. Here is what I want to achieve: a website on the naked domain, www and subdomains + email on the root domain (eg [email protected])

I already had this working with the DNS setup at my domain registrar:

  • 3 CNAME records for the 2 websites that each point to alias.zeit.co for hosting on vercel.com:
    • example.com and www.example.com (the vercel-side config takes care of showing the same website)
    • foo.example.com
  • 2 MX records for using fastmail:
    • example.com points to in1-smtp.messagingengine.com and in2-smtp.messagingengine.com

It all worked perfectly and I was able to receive emails sent from google and hotmail but then someone from a custom domain tried to send me an email on [email protected] and it ended up being sent to [email protected] (the vercel webservers).

With googling I managed to understand that having a CNAME record point to alias.zeit.co for the website at example.com interferes with the fastmail MX record for example.com. There was some mention of using a page redirect which my registrar did not offer which is why I switched to cloudflare.

But now I’m not sure what to add to the DNS setup. Currently, I have the MX records as well as the CNAME records set up in cloudflare for www.example.com and foo.example.com but NOT for the naked domain example.com and the DNS config page is giving me a warning to configure the root domain but I don’t know what exactly to do to avoid the mail issue I had before.

I have also already set up a redirect rule for example.comwww.example.com according to the 1 cheat sheet example on Redirect Rules Cheat Sheet though I’m not sure that will do anything without a CNAME or A record for example.com

I’m currently waiting for Cloudflare to become the nameserver (I have updated the NS records) so I can’t test anything yet.

I’m sure this is explained somewhere but I have spent a few hours searching and did not find a clear answer and my only way of testing is asking that other person to send me a mail since my own gmail account worked fine from the start.

I think I found a hint about the correct solution: Normally an A record is needed for the root domain but cloudflare uses CNAME flattening to convert CNAME into A. The docs say to add a CNAME record that points to cloudflare for the root domain and that will in turn trigger the redirect rule to www. But I can’t find the target to fill in for the CNAME record.

I also found a mention that an A record for the root domain is added automatically once cloudflare has become the nameserver but that has not propagated through the DNS network yet so I can’t confirm that.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.