Free Custom Domain Email with Cloudflare and Gmail

Sending email from a custom domain looks more professional. Most hosting companies even offer it as a plus feature. But setting up and dealing with your own email server is genuinely a hassle. It drags in SPF records, domain verification, even reverse DNS. There are MX records too. So if you want your mail to be delivered properly, there is a whole pile of settings to wrestle with.

Most companies handle all of this for you automatically, of course. But the moment you want a custom email service, these challenges show up.

Anyway. Recently I decided to keep my website static, so I have no admin panel. In short, there is no hosting or VPS running in the background, which means I have no server cost. When I looked into how to handle email sending for the sake of a professional identity/image, I saw that Gmail lets you send mail as another person. I was already using mail forwarding on Cloudflare: for example, if you send a mail to [email protected], it lands in my personal account, [email protected].

Now let's go through how I set all this up.

Prerequisites

  • Your domain's DNS must be managed on Cloudflare (the nameservers point to Cloudflare).
  • A Gmail account.
  • Two-step verification (2FA) enabled on the Gmail account. This is required to generate an app password, which I'll get to.

Step 1: Receiving mail with Cloudflare Email Routing

In the Cloudflare dashboard, select your domain and go to Email > Email Routing in the left menu. If you're opening it for the first time, it walks you through a setup flow.

You do two things:

  1. Add a destination address. You tell it where the mail should land, that is your own Gmail address ([email protected]). Cloudflare sends a verification mail there; you click the link and confirm the address. Forwarding won't work until you confirm.

  2. Add a routing rule. For example, everything sent to [email protected] should go to [email protected]. You can write a rule per address, or turn on catch-all (whatever comes to the domain all goes into a single inbox). Catch-all is practical but it also collects spam, so keep that in mind.

When you enable Email Routing, Cloudflare adds the required DNS records on your behalf automatically. You don't need to touch them by hand, but it's good to know what gets added:

  • Three MX records (like route1.mx.cloudflare.net, route2..., route3..., with different priority values). These are the records that say "this domain's mail should come here".
  • One SPF record (TXT): v=spf1 include:_spf.mx.cloudflare.net ~all.
  • And a DKIM record (TXT, like cf2024-1._domainkey...). This is a signing record for Cloudflare's own mail path; it doesn't help mail sent from Gmail, which I'll touch on in the "Limits" section below.

That's it. Now mail sent to [email protected] lands in your Gmail. Test it: send a mail to this address from another account and check whether it arrives in Gmail.

Step 2: Generating a Gmail app password

Now we move to the outbound side. You can't connect to SMTP with your normal Gmail password; Google rejects it. Instead you generate a 16-character special password called an app password.

The prerequisite for this is having 2FA enabled. If 2FA is off, the app password screen doesn't show up at all.

  • Go to your Google account: Google Account > Security.
  • If two-step verification isn't on, turn it on first.
  • Then go to the App passwords section (if you type "app passwords" into the search box you'll find it directly).
  • Create a new app password and give it a name (say "Gmail SMTP").
  • Google gives you a 16-character code that appears with spaces (like abcd efgh ijkl mnop). Save this code somewhere; once you leave the screen it won't show it again.

There's a point here: Google shows the password with spaces between the groups, but when you enter it into the SMTP settings you need to remove those spaces and type it as one continuous string. Keep this in mind while filling in the SMTP server details in Step 3, otherwise the password won't be accepted.

Step 3: Introducing the custom address to Gmail (Send mail as)

The last step is telling Gmail "I can also send from this address".

  • Gmail > Settings (gear) > See all settings > Accounts and Import.
  • In the Send mail as section, click Add another email address.
  • Enter a name and the address you want to send from: [email protected].
  • The Treat as an alias checkbox appears. You can leave it checked; if you uncheck it, an "on behalf of" note may show up on the recipient's side. For the initial setup, leaving it checked gives the cleanest result.
  • The next screen asks for the SMTP details:
SMTP Server : smtp.gmail.com
Port        : 465  (SSL)   or   587 (TLS)
Username    : [email protected]   (the full Gmail address, not just "erdincyasan")
Password    : the 16-digit app password you generated (no spaces, one continuous string)
  • Once you save, Google sends a verification code to [email protected]. Thanks to Step 1, that mail lands in your Gmail. Click the link in the code or enter the code.

When it's done, you can pick [email protected] from the "From" field while composing a new mail in Gmail. Inbound is in Gmail, outbound is in Gmail. You didn't pay a cent.

Where you get stuck: 535-5.7.8 Username and Password not accepted

When saving the SMTP settings in Step 3, this is the error you hit most often. The reasons, in order:

  • You entered your normal Gmail password. You need to use the app password.
  • 2FA is off. Since you can't generate an app password, you're already entering something wrong.
  • The username is incomplete. Not erdincyasan, but the full address: [email protected].
  • You didn't remove the spaces from the app password. Google shows the code with spaces like abcd efgh ijkl mnop; you need to enter it into SMTP as one continuous string (abcdefghijklmnop).
  • An invisible character slipped in while copying. Enter the app password by hand, carefully.

Limits (to be honest)

This setup is free and gets the job done, but it's not magic:

  • It's not a real mailbox. Nothing is stored on the Cloudflare side, it just forwards. If you delete it in Gmail, that mail is gone.
  • Outbound mail technically leaves from Gmail's server. That's why SPF/DKIM alignment doesn't fully line up with your domain; traces of Gmail remain in the header. It's not a problem for personal/small use, but it's not enough for someone looking for a corporate mail infrastructure.
  • If you have serious sending volume or delivery guarantees matter, a separate mail provider (like Zoho, Google Workspace) or a transactional SMTP service is the better choice.

But if you're saying "I just want a professional-looking address from my domain without paying", this duo is exactly for that.

Share