Connect your own domain name to your Gmail account for free!

Owais Shaikh
10 min readDec 6, 2023

--

Is G-Suite too expensive for you? Got a domain from GoDaddy recently and don’t want to pay for their email services? Or perhaps you want unlimited aliases! Here’s a quick, easy, step-by-step guide on how to sign into your Google account with your custom domain, and send and receive email with it using Gmail — for absolutely free, no MailGun or other forwarders needed! (you still need to pay for the domain obviously)

You will need:

  • A domain (I use GoDaddy in this guide, but any registrar will do)
  • A normal Google Account
  • A Cloudflare account

Note: using GoDaddy isn’t necessary, you can also use Google Domains, SquareSpace or even Cloudflare’s own registrar. I used it because it was the cheapest available option for the domain I wanted.

You can also skip steps that don’t apply to you.

Step 1: Buying a domain

You can visit the GoDaddy domain search engine and buy yourself a domain. If you do, make sure you select “no thanks” for the “custom email address” option. I’d recommend leasing it for 5+ years if you intend to make this your personal email.

Step 2: Connect domain to Cloudflare

We’re using Cloudflare for the following reasons:

  • Unlimited aliases (email “usernames” like name@domain.com)
  • Fast performance (thanks to Cloudflare’s routing)
  • DMARC analytics and management
  • Unlimited emails per day at 25MB per email (almost the same as Google’s limit)
  • Additional TLS encryption

Make a Cloudflare account if you don’t have one. If you do, sign into your Cloudflare account, open your dashboard, click the “Add site” button at the top and enter your domain name in the text box displayed.

Adding a domain to Cloudflare

Click on continue. You will be taken to a pricing page. Scroll to the bottom and select the Free plan ($0), and click continue again.

You’ll need to update your nameservers next. Copy or take note of the nameservers displayed.

This is where you hand over management of your domain to CloudFlare.

Open GoDaddy, go to your domain (My Products → Domains → (your domain) → DNS). Enter the DNS management tab for your domain, then go to “Nameservers” and paste the two domains you got from Cloudflare.

Setting custom nameservers on GoDaddy

Save the changes on the GoDaddy page. Switch back to the Cloudflare tab, and click the “check nameservers button”.

Note: this step can take a while. Keep checking to see if this step is successful.

If you have any DNS records on GoDaddy or your registrar, copy them to your Cloudflare DNS records setup. You can also do this later by visiting DNS → Records in the sidebar.

Complete the handover to Cloudflare by copying over all your DNS records

Here’s the fun part now, configuring your domain to work with email!

Step 3: Enable email routing on your domain

Cloudflare has a feature called “Email routing”. It can route emails sent to your domains through their mail exchange servers (kinda like a postal service). When someone sends you an email, it will first go through Cloudflare servers, who will then forward it to your recipient.

From the sidebar, select Email → Email routing, and enable it.

You can have different email addresses for different purposes on your domain (me@domain.com, burner@domain.com), as many as you wish!

You can set two types email addresses

Catch-all address: If you want emails sent to you at any address on your domain (me@domain.com, blahblah@domain.com etc), you can use a “catch-all address”. To do so, add a catch-all address in the email routing menu, set the action as “send to email”, and set the destination to your personal Gmail address (<youremail>@gmail.com). Enable it once everything’s set up.

Catch-all email routing

Custom address: You can also set up specific addresses with different rules, for e.g.: one that accepts emails, and another which rejects/drops them. This can be helpful if you want to regulate the channels emails enter your inbox through. This is useful if you want a personal email address to log into your Google account (such as name@domain.com), another one to put in résumés (contact@domain.com), and so on…

The custom address menu
Adding an email address

Note: you can use catch-all and custom addresses at the same time too!

After setting this up, Cloudflare will send a verification email to the destination address you set. In the email sent to you, click “Verify email address”, then activate Email Routing in the page that opens up. Your destination address status should now be “verified” (and you should have 3 MX records in your DNS records).

Step 4: Receiving emails via Gmail’s POP server

Log in to gmail.com in a new tab (with the destination email account you used). Go to Settings → Forwarding and POP/IMAP and select “Enable POP for all mail.”

Enabling POP to receive mail

🥳 And done! Try sending an email from another account to your custom address.

It worked!

Note: There may be a small delay in receiving your first few emails.

Step 3: Sending emails via Gmail SMTP

POP/IMAP is only used to retrieve email into an inbox, kinda like walking up to your mailbox and checking if you have mail. Receiving junk/spam email isn’t really a risk, which is why finding burner “emails” is so easy.

Sending email is done via SMTP. When you click “send” in Gmail, your email goes from your outbox to an SMTP server, and then to the internet. SMTP has a higher potential of being misused as a source of spam. This is why providers generally have stricter controls around SMTP to prevent themselves from tarnishing their reputation.

However, there is a trick here. Google lets you route your emails through your own network config if you don’t want to use theirs, which is exactly what we need. We will be sending emails from Google’s SMTP servers to the internet, but through Cloudflare’s servers.

Visit https://myaccount.google.com/security (make sure you are signed into the same Gmail account you used so far) and enable 2-step verification for your account. I recommend enabling Authenticator and SMS.

Add 2FA to your Google Account if you haven’t already.

Next, we will need an “app password”. This lets us use our Google account to sign into services that don’t support Google’s newer, fancier methods. To do this, simply search for “app passwords” in the search box at the top of the page, and create one.

You will now be shown your app password. Copy this password to your clipboard.

Now open Gmail, go to Settings → Accounts and Import → Send mail as and select “Add another email address”.

A window will pop up, asking you to add information about your email address. Put in the sender name you’d like to display when sending mail and the custom email address you’d like to send emails as (you can use a destination address you set in step 3). Un-check the “Treat as an alias” checkbox.

The final step is to authorize your custom config. Set the SMTP server address to smtp.gmail.com and the port to 587. In the username field, set your original Gmail address (not the custom one!) Finally, paste the app password you created in the earlier step. Select “Secured connection using TLS” and click “Add account”.

You will now receive an email in your inbox with a confirmation email. Click on the link in the email or add the confirmation code in the box shown below and click “Verify”.

There’s just one last step remaining. Cloudflare still doesn’t know what to do when it sees an email from your address, so we need to tell it using an SPF (sender policy framework). An SPF is a TXT DNS record that specifies who’s authorized to send emails on behalf of a domain.

Go back to your Cloudflare dashboard and go to DNS → Records. Create a new TXT record, set the name to your domain name, TTL to auto and the content to the following:

v=spf1 include:_spf.mx.cloudflare.net include:_spf.google.com ~all

Here, we tell Cloudflare that only emails originating from Google’s (and Cloudflare’s) mail exchange network can pass through your domain. This prevents unauthorized access from other SMTP servers, which is a common cause of identity fraud and phishing via emails .

v=spf1 indicates the SPF version (version 1)

include:_spf.mx.cloudflare.net and include:_spf.google.com includes all IP addresses listed in the SPF record of these two. Since Cloudflare is handles your domain, including their SPF record means emails sent through all Cloudflare servers are authorized. Since Google is your mail service, including it means sending and receiving emails through its servers are also authorized.

~all specifies how SPF checks are handled. It does a “soft fail”, meaning if the client IP address is not in the SPF record, Cloudflare will accept the email, but may mark it as suspicious.

The last step is to set a DMARC (Domain-based Message Authentication, Reporting, and Conformance) policy. It tracks all emails sent from your domain and can keep you safe.

In the side menu, go to Email → DMARC Management. Click on “View records”, then scroll down and add a record.

This will autogenerate a DKIM record that you need to save in your DNS records as a TXT record.

Here, v=DMARC1 indicates the DMARC version (version 1)

p=none specifies how email receivers should handle emails that fail authentication. none means the domain owner requests that no action needs to be taken by receivers on failing emails.

rua=mailto:<long hex string>@dmarc-reports.cloudflare.net specifies the email address to which DMARC reports are sent. This is a Cloudflare address tied to your account and is used by the DMARC management tracker to show statistics of emails sent from your domain.

If you want to make your custom email address your default one (G-Suite style), visit Gmail settings → Accounts and Import → Send mail as, and click “Make default” on the custom one . Select “Always reply from default address” if you’d also like to use your custom address for all replies (if you want a single “official” email ID on your domain). If you do not select this option, you will always respond with the address you were emailed to (useful if you want different email addresses for different purposes).

Set your default email address

🎉 Woohoo! You can now send emails from your new custom email address!

Congrats! You can now use your own email with the Gmail user experience. Better than GoDaddy’s email service and free, unlike G-Suite 😉

Log into your Google account with your custom email

You can even log into your Google account with your new email address, like G-Suite users. To do this, go to https://myaccount.google.com/personal-info, then go to Contact info and click on “Email”. Scroll down, click on “Alternate emails”, and add your custom email.

You will be sent a verification email, where there is a link you need to click to confirm the addition.

And it costs $0!

And that’s all it takes to log in to Google with your own email address! 🚀

(Optional) Encrypt emails with your own PGP keys

If you’re like me and you’re coming from a secure email client like Tutanota, you’ll miss how they let you encrypt your emails in addition to the already secure TLS encryption.

There’s a cool Chrome extension named FlowCrypt that lets you do this. It integrates seamlessly with your Gmail and even lets you use your own PGP keys that you generate to encrypt your emails. Pretty cool.

Credits:

--

--