All posts

Blog

How to Set Up MX Records for Google Workspace or Microsoft 365

Illustrated cover for the Email guide "How to Set Up MX Records for Google Workspace or Microsoft 365"

Lots of businesses host their website with one company and their email with Google Workspace or Microsoft 365. It's a popular combination, but it needs the DNS set up correctly. Get the MX records wrong and mail can bounce, disappear into the wrong server, or land in spam.

This guide explains what you need to change for each service, the extra records that help your mail get delivered, and one hosting control panel setting that trips up a lot of people.

A quick refresher: what MX records do

MX (mail exchanger) records tell other mail servers where to deliver email for your domain. When someone emails you@yourdomain.com, their server looks up your MX records and delivers the message to whichever server those records point to.

If your website is hosted in one place and your email in another, the MX records must point to your email provider, not your web host. For a deeper look at record types, see DNS records explained.

Before you begin

  1. Find out where your DNS is managed. It could be your registrar, your hosting control panel, or a separate DNS service. Changes only work if you make them in the place your nameservers point to. Our guide on nameservers vs DNS records can help if you're unsure.
  2. Verify your domain with the provider. Both Google and Microsoft ask you to prove you own the domain, usually by adding a TXT record they give you.
  3. Create users first. Set up the mailboxes in Google Workspace or Microsoft 365 before switching MX, so mail has somewhere to land.
  4. Copy any existing mail. If you already have email elsewhere, plan the migration. Copy old messages over IMAP before you switch, and keep the old service active until you've confirmed everything arrived.

Setting up MX records for Google Workspace

Google's admin console shows the exact records for your account during setup, and you should always use the values it gives you. For many newer setups, Google asks for a single MX record:

Type Name/Host Value Priority
MX @ smtp.google.com 1

Older Google Workspace setups used a set of five records (ASPMX.L.GOOGLE.COM and several ALT servers). If your domain already uses those and mail works, they are still valid. Just don't mix Google's records with records from another provider.

Steps

  1. Log in to your DNS provider.
  2. Delete any existing MX records that point to your old host or registrar.
  3. Add the MX record or records shown in your Google admin console.
  4. Save the changes and return to the admin console to confirm or activate Gmail.

Setting up MX records for Microsoft 365

Microsoft generates a domain-specific MX value in the Microsoft 365 admin center when you add your domain. It typically looks something like this:

Type Name/Host Value Priority
MX @ yourdomain-com.mail.protection.outlook.com 0

The value is unique to your domain, so copy it exactly from the admin center rather than typing it from memory. Microsoft also asks for other records, which commonly include:

  • CNAME autodiscover pointing to autodiscover.outlook.com, which helps Outlook find settings automatically
  • TXT record for SPF
  • Additional records for features like Teams, depending on what you use

Steps

  1. In the Microsoft 365 admin center, add and verify your domain.
  2. Choose to add the DNS records yourself if your DNS isn't at a provider Microsoft can update automatically.
  3. Delete old MX records, then add the MX, CNAME and TXT records shown.
  4. Return to the admin center and run the check to confirm everything is found.

Don't forget SPF, DKIM and DMARC

MX records handle incoming mail. For outgoing mail to be trusted, you also need authentication records.

SPF

Your SPF record lists who may send mail for your domain. A domain should have only one SPF record. Common examples:

  • Google Workspace: v=spf1 include:_spf.google.com ~all
  • Microsoft 365: v=spf1 include:spf.protection.outlook.com -all

If your website also sends mail (for example contact forms) through your web hosting server, or you use a newsletter service, you need to combine all senders into one record rather than adding a second record.

DKIM

DKIM adds a digital signature to your messages.

  • Google Workspace: Generate a DKIM key in the admin console (under Gmail authentication), add it as a TXT record (commonly with the name google._domainkey), then click to start authentication.
  • Microsoft 365: Enable DKIM in the Microsoft security portal and add the two CNAME records it shows (commonly selector1._domainkey and selector2._domainkey).

DMARC

DMARC tells receivers what to do when SPF or DKIM checks fail. A cautious starting record is:

v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com

Once you're confident legitimate mail passes, you can tighten the policy to quarantine or reject. Our guide to SPF, DKIM and DMARC explains these in more detail.

The hosting setting that causes lost email

This catches many people. If your website is on a cPanel or DirectAdmin hosting account, the server may still think it's responsible for your domain's email, even after you change the MX records. When your website (or another account on the same server) sends a message to your own domain, the server can deliver it locally instead of to Google or Microsoft. The message never reaches the real inbox.

To fix this:

  • cPanel: Go to Email Routing (or Email Deliverability / MX Entry, depending on version), select your domain, and choose Remote Mail Exchanger.
  • DirectAdmin: In the DNS or MX records management area, uncheck the option that says the local server should handle email for the domain.

Contact form messages and WordPress notifications are the most common victims of this setting, so test them after you make the change.

Testing your setup

Once DNS has had time to update:

  1. Send an email from an outside account to a new mailbox.
  2. Reply and check it arrives without a spam warning.
  3. Use an online MX lookup tool to confirm only the correct records exist.
  4. Check that the provider's admin console shows the domain as fully set up.
  5. Submit your website contact form and make sure the message arrives.

Common mistakes

  • Leaving old MX records in place alongside the new ones
  • Publishing two separate SPF records
  • Editing DNS somewhere other than where your nameservers point
  • Forgetting to set your hosting account to a remote mail exchanger
  • Switching MX before creating users

Wrapping up

Setting up Google Workspace or Microsoft 365 with your own domain comes down to a few records added in the right place: MX to receive mail, SPF and DKIM to send it reliably, and DMARC to protect your domain. Add the remote mail exchanger setting on your hosting account, test from the outside, and your new email setup should run smoothly.