
I actually write most of my tutorials for myself, so that I’ll remember how I did a thing, and it’s just a coincidence that they are useful to other people. This is definitely one of those cases.
I use Cloudflare on all my own websites and on most client websites. (So, yeah, that was a lot of salts to change after Cloudbleed.) Their free plan offers a lot: SSL, caching, a firewall, email obfuscation, and even some nifty graphs of your traffic. It’s easy to set up and usually goes without a hitch.
Usually.
Automated MX detection at Cloudflare
If you’re setting up Cloudflare for the first time, it will detect all your current DNS settings, which it preserves when you switch to Cloudflare’s name servers, automatically detecting which of them should be DNS only (that is, Cloudflare just sends the traffic through) and which should have Cloudflare’s HTTP proxy, and therefore its caching, performance, and security, applied.
So as long as the MX (Mail eXchange) records for your email are already configured correctly, Cloudflare will identify them and your email will continue to work.
Most of my email runs through Google Apps, but my primary domain, rhymeswithsketch.com, actually uses SiteGround’s mail servers. When I set up the account, Cloudflare identified all of the MX records correctly, and there was no interruption to any of my email. (That’s almost a pity, given how much mail I get.)
What if Cloudflare has the wrong MX records?
I host my mother’s website, dorataya.com, on my SiteGround account. When I set it up, her email ran through GoDaddy, her domain registrar, so I set up the MX records at SiteGround to point to GoDaddy. I later added Cloudflare to the site through SiteGround’s cPanel.
But then we ran into some problems. First, my account at SiteGround was upgraded from GrowBig to GoGeek on account of my resource usage. (That, in fact, was one of my motivations for setting up Cloudflare everywhere.) That meant my name servers changed. This was no problem for any of the domains I owned myself, since I just logged in to Namecheap and updated the servers…six times.
But dorataya.com was registered with GoDaddy, and the password I had for Mom’s GoDaddy account didn’t work. Attempts to get it reset didn’t work too well, either. (Why yes, that was before I started using LastPass and Dashlane.) So the site ended up offline.
Then the domain expired because the credit card on file had expired and we still didn’t have login information.
It took quite a number of months, but eventually dorataya.com became available, so I registered it.
Then I went through the process of resurrecting the website. And here’s where it got awkward.
I already had dorataya.com set up on my SiteGround account as an add-on domain. And I already had SiteGround’s version of Cloudflare turned on for it.
In order to re-scan the site, I had to delete dorataya.com from Cloudflare. That didn’t take too long, and setting it up went smoothly—until I realized that I had not updated the MX records for dorataya.com on SiteGround before activating Cloudflare.
Because the GoDaddy account for dorataya.com no longer existed, it was obviously impossible to use GoDaddy’s MX records. That meant I was going to need to use SiteGround’s MX.
Setting up the MX at SiteGround
This was the easy part, actually. There’s a button in their basic MX entry control panel that lets you revert to the default settings with one click. (And another one to let you use Google’s MX, which was very handy for me.) I clicked “Revert Default” and was good to go…at the SiteGround end.
What I thought I had to do to change MX records on Cloudflare
The next step, of course, was to update the MX records at Cloudflare. Based on the example of my rhymeswithsketch.com account, I assumed the thing to do was to add the same MX records, with the same priorities, as I had at SiteGround.
Wrong.
I could not begin to explain to you why this doesn’t work, because I really don’t know that much about servers. (I’m sure my husband could tell me, but he’s busy packing for a trip.) Whatever the reason, it didn’t work. All the messages bounced.
I attempted to use my Google Fu and didn’t get very far. Cloudflare support has an article about how to add MX records in Cloudflare, but neither their instructions for setting up with an email service provider nor their instructions for setting up with your own email server worked. I got pretty tired of all the bounced test messages.
What I actually had to do to get my mail server to work
This morning I decided to try a little further Google Fu. I found the answer buried in a SiteGround article about MX that doesn’t make any reference to Cloudflare (since all their docs about Cloudflare assume you are activating it through their cPanel).
To point your mail service to us, you should change your MX record of your domain to point to your server’s hostname. For example, if your account is hosted on sitegroundXXX.com, then you should change your MX record to: sitegroundXXX.com.
That’s right: you point the MX record at your external DNS not to SiteGround’s mail servers, but to SiteGround’s web server. That sort of almost makes sense, but it was a long way from obvious.
I removed all of my previous non-functional MX records for dorataya.com from Cloudflare and added the server hostname as a single MX record with a priority of 1.
And behold, there was email. And it was good.
So if you ever need to change your MX records on a Cloudflare account that’s already been set up and the obvious solution doesn’t work, try adding your server hostname as the MX instead of adding your actual MX. Just make sure the priority number on Cloudflare is lower than the ones at your host.
THANK YOU!!! :)
This helped. Thank you so much :)
Thank you! This was exactly what I needed! Your solution was explained well.
Thanks , I was struggling so hard, after hours of searching i’m happy I found this post.
I still have to test it though if my emails will come true.
But thanks for writing this detailed guide.
Thank you! I’ve been spending ages first trying to find the MX record of siteground (which I was told on one guideline), and after finding, copying the MX records of the three priorities onto the godadd’ys DNS MX info. It didn’t work, I was so frustrated.
Then voila, your post saved my life. Thanks ever so much!!!!
DNS can be a real pain in the patootie–more so for client sites as clients may not know where their DNS is managed. Tools like DNS Lookup tell you where you need to go to manage the domain’s DNS records. (In general, the possible choices are at the domain registrar, at the hosting company, and on a third-party site like Cloudflare.)
I am confused. Where do I find the server’s hostname?
Is it the name server? ns1.giowm1135.siteground.biz
Thank you for your help.
I wrote this a few years ago, and since that time, SiteGround has set up a new control panel, which means everything looks different. I can show you where it is for my account, but don’t know whether it will match on yours.

Thank you, this worked for me!