In this dev post, I will describe the steps you can use for sending emails through Gmail SMTP with Cloudflare Email Routing.
There are various reasons why you might want Cloudflare to forward emails directly to your Gmail account, and you, being able to reply directly with your new alias email. For cost-efficiency for instance (no SMTP mail server required, and/or easier to setup and manage than your own one, etc).
In my case for instance, I have Cloudflare with my DNS pointing to Webflow and AWS for the SaaS products and APIs. I don't want to worry about my email addresses. I just prefer to forward them to Gmail directly.
You will see, it's actually very easy and handy thanks to the free Cloudflare Routing option (that has now been available for over two years, part of the free Cloudflare tier!)
1: Create Google App Password
To ensure that the configuration using the alias email works, we first need to create a Google App Password. Otherwise, we will be blocked by two-factor authentication (2FA) when connecting to Gmail SMTP (if 2FA is enabled, which is highly recommended).
To create an App Password for Gmail, go to Create an App Password in your Google account. Direct link: https://security.google.com/settings/security/apppasswords
Give it a memorable name, generate the unique app password, and store it securely.
2: Add Cloudflare Email to Gmail Alias
In Gmail, go to Manage Labels (AKA Settings) → Accounts and Import → Add another email address.
There, type your desire name and your Cloudflare-routed email address.
Check the "Treat as an alias" box, and click next.
3: SMTP Details
Mention the following configuration:
SMTP Server:
smtp.gmail.comPort:
587(it's the recommended TLS port over465, as now outdated).Username: Your Gmail username (the first part before the
@. If your email ispierre@gmail.com, it will bepierrePassword: The generated password you copied from Google App Password.
Encryption: Select TLS
Once saved, you will receive a confirmation email from Gmail. Click on the link to confirm the added email.
4: SPF Record & DMARC Policy
Still in your Cloudflare account -> DNS, add the following:
SPF Record
-
Type:
TXT -
Name:
@ -
TTL:
auto - Content:
v=spf1 include:_spf.mx.cloudflare.net include:_spf.google.com ~all
DMARC Policy
To help both email recipient and sender from threats such as email spoofing, phishing, and spam attempts, you should also add a DMARC Policy to monitor emails. Ensure the p parameter is set to none.
In Cloudflare DNS, create a new TXT record:
DMARC Record
-
Type:
TXT -
Name:
_dmarc -
TTL:
auto -
Content:
v=DMARC1; p=none; rua=mailto:YOU@YOUR-DOMAIN.COM
DMARC with Multiple Email Addresses
To handle multiple emails, you need to add them separated by a comma, one after the other.
v=DMARC1; p=none; rua=mailto:email1@domain.com,email2@domain.com,email3@domain.com
Enjoy! 🥳
You’re now all set! You can send emails using Gmail SMTP with your Cloudflare-routed email address. When replying to emails, your Cloudflare email address should automatically appear in the From: field.
You may also be interested in reading:
☕️ Was this useful? What about offering me a cup of my favorite coffee? Ko-fi.com/phenry 😋
I hope it helps 🤠 Enjoy your day! ☺️


Top comments (11)
Pierre, many thanks to share it so this is what I needed.
Just one question, do you know how to skip spam to be marked in these emails sent by this way?
Everything is working, but all emails are going to spam, any suggestion? Or is it normal because the email account has been configured recently on both sides, Cloudflare and Gmail?
Thanks in advance.
Hi Miquel
Did you figure this out? I'm looking into doing this, and it would suck to have all my outgoing mail marked as spam. :(
Hi Gorm,
Yes, I figured it out. The first thing to keep in mind is that it requires some patience to avoid having your emails marked as spam. It usually takes a few days, around a week, after everything is properly configured—especially the DNS records on Cloudflare.
Since the email account is new, Google needs some time to evaluate the configuration before deciding whether your emails should be marked as spam or not.
I recommend double-checking all your settings, particularly ensuring that your SPF record includes Google (I realized I had multiple SPF records, but I missed including _spf.google.com).
Additionally, I tried manually marking emails as "Not Spam" in other email accounts where I received test messages that were initially marked as spam. This helped Google learn that the emails were legitimate, and after a few days, it definitely worked.
Hope this helps!
Thank you so much for your reply. This gives me more confidence in this solution, and I'll probably go with this then. Great info! :)
Hi - this article has helped me a lot, thank you.
All working but I have a couple of questions:
I'm getting "unable to verify sender" alerts when e-mail messages (sent via Gmail smtp) are seen in the recipient's mailbox (this is MS365/Outlook) so is there any extra DNS config that needs to be added to fix this?
Also - is the SPF record for Gmail smtp: "_spf.google.com" correct? This is mentioned in Google Support for Google Workspace but wondered if personal Gmail (i.e. non business/workspace is also covered by this) or should it be "_spf.gmail.com"? I hope that makes sense - thanks!
You should have received an email from
Gmail Team gmail-noreply@google.com. And the email subject should beGmail Confirmation - Send Mail as <YOUR_CUSTOM_EMAIL_ADDRESS>Have a look in your spam folder (very likely to be in there 🙂).
Hope it helps!
For the last step (DMARC) which email address are we putting in? The gmail one or the custom domain one?
Your custom email address you have added in Cloudflare. Not the gmail one.
Thanks for the post! It really helped me get my email set up.
What advantages/disadvantages does this method have compared to a traditional email hosting account?
Thanks in advance.
Great question! Cloudflare offers many great features, extra security layers, DMARC Management, the "catch-all address" (can be super handy), clear email logs from Cloudflare Email (to check if an email was forwarded to our gmail or not), etc.
How do I set this up so I am sending from my cloudflare email address? In your examples you are using a different gmail address.