Logo

dev-resources.site

for different kinds of informations.

How to Send Emails Using Gmail SMTP with Cloudflare Email Routing?

Published at
8/20/2024
Categories
hosting
cloudflare
email
dns
Author
pierre
Categories
4 categories in total
hosting
open
cloudflare
open
email
open
dns
open
Author
6 person written this
pierre
open
How to Send Emails Using Gmail SMTP with Cloudflare Email Routing?

In this dev post, I will describe here the steps you can use for sending emails through Gmail SMTP with Cloudflare Email Routing. There can be various reason where you 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 our 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 it has now been available for over two years, part of the free Cloudflare tier!)

1: Create Google App Password

To ensure the configuration we will do with the alias email works, we need to create a Google App Password first, as otherwise we will be blocked by the two-factor authentication (2FA) when we authenticate to Gmail SMTP (if 2-Factor Authentication is enabled which is highly recommended anyway).​​​​​​​​​​​​​​​​

For creating an App Password for Gmail, you need to go to Create an App Password in your Google account. Direct link is: https://security.google.com/settings/security/apppasswords

Generate it and keep the unique password safe.

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.

Image description

3: SMTP Details

Mention the following configuration:

  • SMTP Server: smtp.gmail.com

  • Port: 587 (it's the recommended TLS port over 465, as now outdated).

  • Username: Your Gmail username (the first part before the @. If your email is [email protected], it will be pierre

  • Password: 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
Enter fullscreen mode Exit fullscreen mode

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:[email protected]

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:[email protected], [email protected]
Enter fullscreen mode Exit fullscreen mode

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.

I hope it helps 🀠

hosting Article's
30 articles in total
Favicon
How to run your website for Free ?
Favicon
What is Web Hosting and How Does It Work?
Favicon
Different Types of Web Hosting Explained
Favicon
Skycloak
Favicon
Hostinger Review 2025: Speed, Performance & Value for Money
Favicon
How I built my own managed hosting platform
Favicon
ProHoster.info: The Ultimate Solution for Reliable and Affordable Web Hosting
Favicon
Linux Shared Hosting: Balancing Performance, Security, and Cost
Favicon
A $5 to $10 VPS can do a lot more than you think
Favicon
How to Optimize Vercel Costs
Favicon
Best Hosting Provider : Accuwebhosting
Favicon
Why VPS Hosting is the Future of Small Business Websites in 2024–2025
Favicon
Step-by-Step Guide to Hosting Your Website on a VPS Using Caddy Server and Cloudflare
Favicon
Trick or Treat Yourself to 20% OFF Web Hosting – bodHOST Halloween Sale
Favicon
Ayuda por favor!
Favicon
How to host Browser.application projects
Favicon
10 Free Web Hosting Solutions for Static and Dynamic Sites
Favicon
How I host Elm web applications with GitHub Pages
Favicon
Can You Really Host Laravel on Shared Hosting?
Favicon
Best Web Hosting and Domain Providers in UAE: A Complete Guide
Favicon
Newt Labs - WordPress Site Care from Β£79 per month
Favicon
Hosting Web Application For The Web
Favicon
Free Hosting Using Github pages
Favicon
Connect Namecheap Domain to KnownHost
Favicon
Deploy Laravel Projects to Namecheap Server on Github Push with 3 Easy Steps (The only tutorial you would every need)
Favicon
WP Raptor Host Review – Unlimited WP Sites, Access for Life
Favicon
Detailed Guide: Choosing the Right WooCommerce Hosting
Favicon
Why do I need a professional email?
Favicon
The Ultimate Guide to Choosing the Best Web Hosting for WordPress in 2025
Favicon
How to Send Emails Using Gmail SMTP with Cloudflare Email Routing?

Featured ones: