Introduction
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 include:_spf.google.com include:_spf.mx.cloudflare.net ~all
mx include:_spf.google.com
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; rua=mailto:you@example.com; 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., your.name@gmail.com
).
Go to you Gmail inbox and click the link in the confirmation email from Cloudflare.
Next, add your custom email address (e.g., special@example.com
) 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 https://myaccount.google.com/apppasswords 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 smtp.gmail.com
Leave the Port option as is (587).
Username is the part of your Gmail address before @. For example, if your Gmail address is your.name@gmail.com
, then enter your.name
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.
Conclusion
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:
- Cloudflare’s email routing: https://developers.cloudflare.com/email-routing/
- Change the domain’s authoritative nameservers: https://developers.cloudflare.com/dns/zone-setups/full-setup/setup/
- Setup Cloudflare email routing: https://developers.cloudflare.com/email-routing/get-started/enable-email-routing/
- https://myaccount.google.com/apppasswords
- Detailed instructions on adding a new email address: https://support.google.com/mail/answer/22370
- Gmail account settings: https://mail.google.com/mail/#settings/accounts
Leave a Reply