Email in your own domain with Cloudflare (and Gmail)

Contents

If you have your own domain and you are unable to receive and send emails from this address because it involves additional costs, Cloudflare has prepared the perfect solution for you.

Email Routing (email forwarding) is a free service worth considering.

To use this option, our domain must be managed on Cloudflare’s DNS servers. If we have MX (mail) records for another service, we will need to delete and replace them.

Email Routing involves setting an email address in the domain from which each email received will be forwarded to another mailbox.

If your business email address is on a Gmail domain, why not start using email on your own domain. You will gain more prestige and professionalism, even though nothing will really change for you, because we will continue to receive mail on the mailbox that you have been using so far.

Before we start playing, it’s best to know the limitations of this service.

Service limitations

  • The service supports domain with linguistic characters, the so-called tails (ąściź in the Polish language), but does not support address prefix with these characters;
  • If mail sent to an address in the domain is not delivered to the delegated mailbox (for various reasons), the sender is not notified about it in the form of a non-delivery report;
  • In the free version, the email address can only be in the main domain. Using email forwarding in a sub-domain (sub-domain) requires upgrading to a higher, paid package;
  • If you are used to using Gmail’s email address combinations (i.e. address+label@example.com) or the variance of email addresses (email.address@example.com is the same as emailaddress@example.com), in this service, each address is treated separately and will not work as by default in Google mail (this is to change in the future);
  • Some service providers with strict DMARC policies may cause problems with delivery of the email address from the service to the target mailbox;
  • The service does not offer the option of composing a new message or replying from an address in the domain. But are you sure? We’ll see later in this post where we’ll try setting an email address as an alias in Gmail.

Service setting

After logging in to our panel in Cloudflare and adding our domain (I will not go into this aspect here), you will see the Email option on the left.

Cloudflare - Email Routings - Get Started

By clicking the Get started button we will start setting our addresses.

Cloudflare - Email Routing - Get Started

First, we must select our domain alias and then specify where the mail should be forwarded.

After clicking the Create and continue button, we will proceed to the verification stage of our destination address.

Cloudflare - Email Routing Verification

We will receive an email from Cloudflare to our email address, in which we will have to click the Verify email address button.

We can do this from any device. At this stage, we won’t have to log in to Cloudflare, so you can set it up on your computer and confirm it on your tablet or mobile phone.

In the last stage, add DNS records responsible for mail handling (MX and one TXT).

If our domain was already set up in Cloudflare (or we transferred it from another service provider along with their entries), at this stage we will be informed that we already have MX records and they cause a conflict. You should remove them and add the ones recommended by Cloudflare.

Cloudflare - Email DNS records

Once this has been done, returning to the Email section on the left side of the menu, we will receive confirmation: Routing status: Enabled.

Here’s what it looks like on my domain.

Cloudflare - Email Routing Enabled

In the Routes tab we can see our set alias address, add additional ones and check which email addresses are approved to receive emails.

With the first alias, we confirmed our email address at this stage. For each subsequent one, we need to add it in the Destination addresses section before setting an alias pointing to it.

Check the configuration

At this stage, we need to send an email address from another email address that we have set in Cloudflare. If the e-mail has arrived, everything works as it should and we can proceed with further configuration if we need it.

Statistics

Oprócz samego przekierowywania poczty, usługa Email Routing oferuje na stronie głównej przejrzyste statystyki oraz dziennik (log) pokazujące co i kiedy zostało wysłane do nas.

Spam and other junk mail

Forwarding emails through Cloudflare does not interfere with the type of messages we receive. On the side of our e-mail address, we should take care of appropriate filtering of junk messages, because Cloudflare does not affect this.

Cloudflare will reject messages that do not pass the default verification and are very likely spam. You can read more about it in the Spam and abusive traffic section.

Secure DNS settings

If everything is working as it should, the last step is to secure our email-related DNS entries so that we don’t accidentally mess them up.

Cloudflare - Lock DNS Records

To do this, go to the Settings tab in Email Routing and click Lock DNS records

 <script async delay="https://dariusz.wieckiewicz.org/g/serve.js?client=ca-pub-5380116874441486"
      crossorigin="anonymous"></script>
 <ins class="adsbygoogle"
      style="display:block; text-align:center;"
      data-ad-layout="in-article"
      data-ad-format="fluid"
      data-ad-client="ca-pub-5380116874441486"
      data-ad-slot="9220966978"></ins>
 <script>
      (adsbygoogle = window.adsbygoogle || []).push({});
 </script>

Sending and replying from a domain (Gmail)

Even though Cloudflare officially does not offer the option of replying or composing a new message from our e-mail address in the domain, it does not mean that it is not possible. Gmail has the option to set our address as an alias. Let’s see if it works.

First, we need to set a one-time password for the application from the Google Account level.

  1. Go to Google Account;
  2. Go to the Security section (Security);
  3. In the Signing in to Google section, select [App passwords]. We confirm the transition to this section by entering our account password;
  4. From the Select app list, select Mail and from the Select device list, select Other - Custom name. Enter any name and press the Generate button;

We return to Google Mail (Gmail).

  1. Go to Mail Settings > See all settings;
  2. Select the Accounts tab and in the Send mail as item, click Add another email address;
  3. In the Email address field, enter the one you set on the Cloudflare side and click Next Step;

At this stage, let’s make sure that our e-mail address was treated as an alias (Checked box Treat as an alias)

  1. In the SMTP server field, change route1.mx.cloudflare.net to smtp.gmail.com and leave port 587;
  2. In the username field, enter our Gmail address (login@gmail.com);
  3. In the Password field, enter the one generated at the beginning (not our account password).

When we press the Add account button, Google will send an email with a verification code to our Alias. When the message arrives, enter the received code and confirm.

This way, we will be able to write a new message and reply from our alias. Even though Cloudflare doesn’t support it, Gmail will do it for us.


In the same section in the mail settings where we added our alias, we can select the default mail behavior (When replying to a message) by selecting the Reply from the same address to which the message was sent (Reply from the same address to which the message was sent).

Thanks to this, we will not have to switch between Gmail and the alias address every time.


And so, in the series “why it’s impossible, if is possible”, we have set the possibility of receiving, replying and sending mail from our alias set from DNS and Cloudflare.


This type of solution is, in a way, an alternative to domain e-mail for people who want to use Gmail but do not want to invest in Google Workspace.

Regards.

Comments
Categories