skip to content
Tiny Tech Tips

Custom email domain with Cloudflare and Gmail

How to send and receive emails with a custom Cloudflare domain.

Setup to receive emails

  1. In your Cloudflare dashboard, go to Websites > your website > Email.
  2. Click Add records and enable and Cloudflare will automatically set up the MX and TXT records as needed. We will make some modifications to them soon.
  3. Add a destination address where emails should be forwarded to. I tend to use Gmail’s address variation and use something like [email protected]. This will forward emails to [email protected] as expected. You’ll need to verify this email before Cloudflare accepts it.
  4. Add a new custom address like [email protected] with the Send to an email action and the preferred destination.

This is enough to start receiving emails. If you’d like to send emails from the custom domain as well, continue with the following section.

Setup to send emails

  1. Add a new DNS TXT record with name _dmarc and content v=DMARC1; p=none; rua=mailto:[email protected]. This tells email servers what to do when senders can’t be verified and the report will be sent to the specified address.
  2. Cloudflare should have added another TXT record where the content value contains v=spf1 .... Edit this record to enable Gmail to send emails on our behalf. The content should look like this: v=spf1 a mx ~all.
  3. In your Google account, under Security, create a new App Password for the Mail app. Save the generated password to use in a later step.
  4. In your Gmail settings, under Accounts and import, add another email address to the Send email as section. Pick your name, untick Treat as an alias, and use the custom domain email address in both email and reply-to address fields.
  5. In the next window, set SMTP server to, leave port unchanged, add your gmail username (e.g. username from [email protected]), and the app password from earlier.

When composing an email from Gmail after this point, you should have the option to pick your custom domain address as a sender.

Note: your original [email protected] will be visible in the email header, in case this is important to you.

More detailed info on this topic here.