Moving Your Site Hosting but not Your Email

Jun 18, 2024, 2:25 PM @ đź“‘ The Office

My website hosting provider also provides email. I want to change hosting to Vercel for ease of management and so I can take advantage of Vercel's Next.JS hosting features. But, I don't want to mess with my email. This StackExchange question covers how to do exactly that. Here's an overview of the process.

  1. Check your MX DNS records. Are they pointing to the apex domain (@) or to a subdomain? If they are pointing to the apex domain, then change it to point to a subdomain, like mail.example.com. This is because if they point to the apex domain, the mail will be directed to Vercel when we change the A records. Vercel doesn't know what to do with our email. So, let's not do that!
  2. Set up Vercel to recognize the custom domain. That should include the apex domain and the www subdomain.
  3. Change our current name server's @ and www A records to point to Vercel's server IP address.

That sounds simple enough, right? Let’s explore each step in greater detail below.

1. Check the MX records

One comment on the StackExchange question mentioned that MX records aren't mandatory. This was confusing for me, because this blog post about MX records for email outreach (beware the emojis) says otherwise.

Logging into my name server provider, I looked for an MX record, but I didn't find one. Hmm. However, I do have an SPF record:

my-domain.com.  14400 IN TXT "v=spf1 a mx include:somewebsite.com ~all"

I don’t know what that means. Let me check…

What are SPF records?

Confirming people’s identities in long-distance communication is an age-old problem. Imagine I want to send you a message. I write it on a paper, stick it in a coconut, and tie the coconut to a swallow. When the swallow arrives, you open the coconut and read the message. How do you know that message was really sent by me? Well, you would check my SPF record, of course. My SPF record will tell you exactly what kind of swallow I would use (African or European?), and which variety of coconut, as well.

This old HTTP-only site from 2006, Open-SPF.org, tells us more. SPF stands for “Sender Policy Framework.” It helps an email recipient check if the email sender is real, or an impostor. The SPF record is made of some keywords called “mechanisms.” In my example, the mechanisms are a, mx, include:somewebsite.com, and ~all. The recipient email server will check these mechanisms in order from left to right. Here’s what they check.

First, the a means to check the A record of the domain, my-domain.com.. If it matches the sender’s IP address, then it’s cool, and the email goes through. Same goes for mx: check the MX record. Next, the include:somewebsite.com part tells the recipient to check the SPF record of that website. If this include mechanism doesn’t work, the whole SPF record check will fail. Last, the ~all part says to soft fail if the other checks didn't pass. That means the recipient should accept the email, but mark it as spam.

But my site doesn’t seem to have an MX record. What gives?

A search for my site on DNSchecker.org says that my site has no MX record set. The FAQ on Open-SPF.org says that the server will just use the A record for the domain if the domain has no MX record. This site says that the RFC 2821 standard allows this, but it’s not a good idea because it means the email sender has to go through more DNS look-ups before it can deliver your email to the right place. This means emails I receive are being resolved through the apex domain, not through a subdomain like mail.example.com. I think this means that the email will break if I point the apex domain A record to Vercel.

2. Setting up Vercel

Vercel has name servers, as detailed in this guide. But I don't want to use their name servers, so I need to look elsewhere for information.

What we need is to add a domain and point it to Vercel's server, detailed here. In Vercel, go to Settings > Domains. Add the apex domain and the www subdomain, too. It will prompt you to go to your name server and add an A record for @ to Vercel's IP address. The example in the docs shows the IP address of 76.76.21.21.

The documentation mentions verifying domain access if the address is in use by another Vercel account.

3. Changing the DNS records

Now that I’ve got my other DNS ducks in a row, it’s time change the A records. Here’s what records need to be added or changed:

  1. Add an MX record pointing to mail.my-domain.com. Mail.my-domain.com already points to the correct IP address, so no more changes should be necessary. I’m not entirely sure this step necessary, though. It’s probably safer to add it, than not. It needs further confirmation.
  2. Click the buttons in the Vercel UI to set up a custom domain there.
  3. Change the A record for @ to point to Vercel’s server. Also, if alternative domains or subdomains are also A records instead of CNAME records, then change those to point to the apex domain, or also update them to point to Vercel.

That’s it! If all goes well, email will stay running with no issue, and the site will go live at its new home. My final comment is this—DNS and web hosting management is tiring and extremely tedious. I’m glad it’s not my job.


Profile

Written by Randy Josleyn—Language learner, language teacher, music lover. Living in Beijing, Boise, and elsewhere