Email forwarding with Google Domain and Cloudflare

Posted in Category • May 4, 2020

I am one of those people who would have to use a custom email address with their own domain name. I mean, is not fun, and are nicer, but my desired address has already been taken. And like many others, I have already own a domain, so naturally I want to take advantage of that and having a custom domain email address

It used to be very simple, most domain name providers do offer email forwarding which you can then point it to your existing inbox and call it a day. However, it gets complicated when you want to throw in CloudFlare CloudFlare provides acceleration and security for your websites. It dose that by proxy all requests to your domain to it own servers, which then send the corresponding request to your own server and does some processing on the response before sending it back to the client. The proxy part involves dynamic routing to different edge servers based on client location and the server availability, the only way they could do that is to control the DNS records of your domain name, that’s why CloudFlare requires you to use their name servers.

, as well as DKMI

and SPF


A popular choice was to use Mailgun, as they do provide mail servers which you can create MX records to point to, and create rules to forward incoming emails to their desired inbox. However, as of early 2020, Mailgun changed their plans to exclude the rules/routing functionality needed to do this, so I have to look for a different way to have email forwarding.

Domain and email, the basics

First, let’s take a look at what happened when someone send an email to your custom domain email address. Assuming the message was sent from their email client:

  • The message is sent to their mail server using SMTP.
  • Their email server will lookup the the MX DNS records associated with your domain name, which points to your mail server.
  • The two mail servers will then communicate. During that process, SPF are used to determine whether the email and the receiving mail server address are trust worthy. Some email services will refuse to deliver a message if the target mail server is not listed in the SPF record.

Custom domain email address

First, let’s take a look of the options we have to establish a custom email address using our own domain name.

Using domain name provider’s email forwarding service.

Most domain name providers will offer email forwarding service, when you can effortlessly map one (or many, even wildcard) email address associated with your domain, the one you purchased from them, and have it point to one of your existing email address.

This is the easiest one I’m a big fan of Rich Hickey - the creator of Clojure. One of his most famous talk is Simple make easy, which clarify the subtle different between simple and easy. I’m intentionally using the word easy here, since this approach can be done with a few clicks in the domain name provider’s control panel, however there actually are quite a few things going on behind the scene. It is easy to do, but it is not simple.

, but it is also the least flexible option. What this really does is that the domain name provider will populate a MX record for your domain, pointing to their own mail server. When the message get there, the mail server will forward it to your own email address.

The problem with this approach is that you have absolutely no control over those MX records, as well as the TXT records required for domain name and email address validation, namely DKMI and SPF. You will risk your emails went straight to the spam box. Moreover, if you are going to use CloudFlare, which requires you to use their own DNS server, then this is no longer viable.

Running your own mail server

This can be done, there are so many articles on the internet explaining how one could do this. However this is not an option for me since it is too big of a hassle to maintain, who will have the time to do it?. Reliability is a real concern too, and email is such a too critical of a thing to risks it.

Moreover, this has many disadvantages compare to email forwarding. For example with email forwarding you could use any of the webmail client you wanted - the nicer ones such as GMail or Outlook. With email forwarding you don’t really need to worry about storage, security, spam .etc, which all are provided from your existing email services.


I consider this the last escape hatch I would take if none of the ways work. This for sure will work but it requires paid and create it own problems.

Hosted email services

I did look at the hosted email services such as Fastmail, however they are all a bit expensive, and have some limitations that look unreasonable to me.

What I really wanted, is to replicate the email forwarding functionality - preferably using only free services.


Like I mentioned earlier, one of the popular choice for people in this situation is to use Mailgun. Mailgun provide the forwarding mail server part of the equation, what’s left is for you to setup the forwarding rule and the DNS records within your DNS provider, in this case I’m talking about CloudFlare. I was happy with this setup, up until Mailgun changed their service tiers.

Hosted mail forwarding services

There are hosted services out there that provide email forwarding features. They are also not meeting my needs so again, no go for me. To name a few of these:

  1. ImprovMX: 10MB attachment size limit. Even their Premium plan, which is quite expensive at $9/month has an attachment size limit of 25MB. I don’t usually have big attachment files but 25MB seems very small by today standard. ( ¯_(ツ)_/¯

  2. they are free and open source, which is good. However they are really new and I don’t really trust them.

Email forwarding with Google Domains

I was using before found out that if you get your domain from Google, they will let you use their email server for forwarding, even if you don’t use their DNS server. Nice!

Following is the official guide explaining the steps needed: It is quite detailed and provides everything you need so I highly recommend you to read it and follow those steps.

In brief, you will need to enable email forwarding on you Google Domains, then setup the following DNS records:

Type Name TTL Priority Value
MX Blank or @ 1H 5
MX Blank or @ 1H 10
MX Blank or @ 1H 20
MX Blank or @ 1H 30
MX Blank or @ 1H 40


There you have it, my thought process and the story of how I end up with my current setup. I hope that you will find this post useful. Cheers!