How to Use Gmail with Custom Domain Name and Cloudflare



You can use a basic Gmail account (i.e., not a Google Workspace account) to send email with a custom domain by using Gmail’s “Send mail as” functionality and Cloudflare’s email routing service.

This guide will show you how to use Gmail to send emails with your custom domain and Cloudflare’s email routing service, without requiring a separate email server.

Configure Cloudflare

First you’ll need a domain configured to use Cloudflare, if not you’ll need to change the domain’s authoritative nameservers first. Then you can setup Cloudflare email routing.

You’ll be given some DNS records to set up by default, but you’ll want to alter these slightly.

Edit SPF record

Your spf TXT record will need to look like this:

v=spf1 a mx  ~all

mx has been added to indicate that Google can send on our behalf, along with Cloudflare.

Edit DMARC record

Change it so it looks like this:

v=DMARC1; p=none;; aspf=r;

The email address in the rua field is where email providers will periodically send you aggregated reports about your domain’s email.

Domain policy p is set to none.

Other selected options are quarantine and reject if sending mail fails to pass DMARC checks).

The SPF alignment policy aspf is set to relaxed r.

The above is critical for preventing email from your custom domain being bounced or rejected because it is not DKIM signed by Gmail.

Create Email Route

In your Cloudflare dashboard, click the Email option then add a destination address using your Gmail address (e.g., 

Go to you Gmail inbox and click the link in the confirmation email from Cloudflare.

Next, add your custom email address ( in your Cloudflare dashboard and select it for routing to the gmail address you just confirmed.

Configure Gmail

Next we’ll configure Gmail.

Create Google App Password

First you’ll need to create an email app password in your Google account.

Note: You might need to enable 2-factor authentication for your Google account before you can use app password.

Go to and choose Email from the “Select app” dropdown and Other for the device.

Copy the password that’s generated for you.

Add Email Address to Gmail’s “Send mail as”

Go to your Gmail account settings and in the Send mail as: section, click Add another email address option.

In the pop-up, enter the email address with your custom domain.

Untick the Treat as an alias option.

Click the Specify a different “reply-to” address link and enter the same custom email address in there.

Then click Next Step.

In the next screen, overwrite the value for SMTP Server with

Leave the Port option as is (587).

Username is the part of your Gmail address before @. For example, if your Gmail address is, then enter for the Username field.

Password is the email app password that you generated in the above step.

Click the Add Account button. You’ll be sent an email to the custom email address you entered. Click the link to confirm.


You’ll now be able to compose emails in Gmail and set the sender to your custom domain email address. When people reply, Cloudflare will route these emails back to your regular Gmail account, all without you needing a separate custom mail server.

Links for reference:


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.