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
-
A Domain: You own a domain (eg.
dev.me) and it is using Cloudflare DNS -
A Gmail Account: You have a standard personal Gmail
account (eg.
personal@gmail.com)
Goals
Here are our goals:
-
Personal Gmail (
personal@gmail.com) to remain as the primary UI -
Emails sent to
me@dev.meto appear inpersonal@gmail.com -
Emails sent from
me@dev.meto appear as if they originated from that address, fully signed and authenticated, avoiding the dreaded "via gmail.com" header - Most importantly: free
To achieve this, we'll use the following stack:
- Cloudflare: Routes inbound mail to your personal Gmail
- Mailtrap: SMTP relay to handle outbound mail so you don't look like spam
- 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:
-
Head to your
Cloudflare Dashboard, then enter your domain of choice (eg.
dev.me) -
Then click on
Email, thenEmail Routing -
Add your existing personal Gmail (eg.
personal@gmail.com) as aDestination Addressand follow the steps to verify it -
In the
Routestab, enableCatch-all addressto 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:
-
Head to the
Sending Domainssection on the sidebar and add your custom domain -
Click into your domain, and follow all steps needed to be done in
the
Domain Verificationsection (ensure all checkmarks are green) -
After that, head to
Settings, thenAPI 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:
-
Head to your personal Gmail, then
SettingsandSee all settings -
Under
Accounts and Importtab, in theSend mail assection, click onAdd 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
- SMTP Server:
-
Ensure the
Reply from the same address to which the message was sentoption 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:
- Start creating a new Google Account as per usual
-
When prompted for a username, select
Use your existing emailinstead and type your custom email address (me@dev.me) -
Once the account is created, upload a profile picture, and your
outbound emails from
me@dev.meshould 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.