The Poor Man's Custom Domain Email

I want a custom domain email, but I'm too poor to afford the Google Workspace $12/month tax. This article contains what I did to set up a professional, highly-deliverable, custom domain email for free.

Prerequisites

  1. A Domain: You own a domain (eg. dev.me) and it is using Cloudflare DNS
  2. A Gmail Account: You have a standard personal Gmail account (eg. personal@gmail.com)

Goals

Here are our goals:

To achieve this, we'll use the following stack:

  1. Cloudflare: Routes inbound mail to your personal Gmail
  2. Mailtrap: SMTP relay to handle outbound mail so you don't look like spam
  3. Gmail: The email UI you're already familiar with

Receiving Mail via Cloudflare

To receive emails sent to the dev.me domain, we utilise Cloudflare's free email routing service to route all emails to our personal Gmail.

Configuration steps:

  1. Head to your Cloudflare Dashboard, then enter your domain of choice (eg. dev.me)
  2. Then click on Email, then Email Routing
  3. Add your existing personal Gmail (eg. personal@gmail.com) as a Destination Address and follow the steps to verify it
  4. In the Routes tab, enable Catch-all address to forward everything (*@dev.me) to your Gmail

The catch-all setting is optional, but having it enabled means you don't actually need to manually create aliases for every email address you want to use. You can start receiving emails from netflix@dev.me or contact@dev.me, and they will all land in your personal@gmail.com inbox.

Sending Mail via Mailtrap

To send mail that doesn't look like spam, we must use a dedicated SMTP relay. For this, we'll use Mailtrap, which has an extremely generous free tier (4,000 emails/month as of this writing).

Create your account, then follow these steps:

  1. Head to the Sending Domains section on the sidebar and add your custom domain
  2. Click into your domain, and follow all steps needed to be done in the Domain Verification section (ensure all checkmarks are green)
  3. After that, head to Settings, then API Tokens, and create and note down a new token that you will use for the Gmail integration

Gmail Integration

Now the fun part, combining everything together:

  1. Head to your personal Gmail, then Settings and See all settings
  2. Under Accounts and Import tab, in the Send mail as section, click on Add another email address, and use the following details:
    • SMTP Server: live.smtp.mailtrap.io
    • Port: 587 (TLS)
    • Username: api
    • Password: API key from Mailtrap that you created in the previous section
  3. Ensure the Reply from the same address to which the message was sent option is checked so that your replies automatically use the same email address that received the email in the first place

At this point, you should try to send an email from the me@dev.me email address to see if it works.

Gmail Profile Picture "Hack"

If you tried sending yourself an email from the integration above, you'd have noticed that the profile picture of your me@dev.me account doesn't have a proper profile picture.

To fix this, we need to actually create a Google Account with the custom email address:

  1. Start creating a new Google Account as per usual
  2. When prompted for a username, select Use your existing email instead and type your custom email address (me@dev.me)
  3. Once the account is created, upload a profile picture, and your outbound emails from me@dev.me should start showing your profile picture after a few hours

NOTE

If a prompt appears to try to convert this account you just created to use a Gmail inbox, ignore it. Remember that you are not creating a new Gmail inbox, just a new Google account that uses your custom email address.

Security & Preventing Spoofing

CAUTION

If you have followed Mailtrap's instruction as is when adding the DNS records, your email is likely susceptible to spoofing attacks! Please read on to remediate!

Firstly, tighten your SPF record in your Cloudflare DNS.

Find the TXT record for SPF and ensure that Mailtrap is also included in the authorised list, since emails are sent from Mailtrap. The ~all (tilde = soft fail) setting should be set to -all (dash = hard fail) as well, marking senders not on the authorised list as unauthorised, not just as suspicious.

# Correct SPF example:
v=spf1 include:_spf.mx.cloudflare.net include:spf.mailtrap.live -all
#                                                               ^ Ensure it's not `~`

More importantly, tighten your DMARC record.

If you've copy-pasted Mailtrap's example, then it's likely set to p=none (monitor only). For a personal domain where you are the only sender, you should set this to p=reject to block anyone trying to spoof you.

# Correct DMARC example:
v=DMARC1; p=reject; rua=...
#           ^ Ensure it's not `none`

Since these are DNS changes, they may take some time to propagate. Check the health of your new email by using CanIBeSpoofed to do an automated check, or Kevlarr to try to spoof as your newly created email. Afterwards, you should ideally do another sanity check that sending emails from your new domain works as expected as well.