Configuring email forwarding to gmail with cloudflare and

Ok recently i moved my domain ( into digitalocean. Old server had email server, cpanel, etc so when i moved to my lemp server i got http working perfectly but no email. I read about setting up email server but it looked like resource-consuming and way too many problems (security issues, spam, etc, etc) So I thought forwarding everything to gmail. I found 2 pretty neat tutorials and in this post:

That helped me configuring postfix to forward emails, but i needed help with cloudflare and, as nic doesn’t allow you to configure anything but ip-dns pair.

So here we go

Step 1) configure domain go to, login and choose the domain you want to use with cloudflare (for example, then hit “delegar” on dns delegation delete anything you had and enter this 2

hit save, the update will happen in less than a day (yes, sucks, sorry)

Step 2) go to cloduflare, login (or register) and start step by step tutorial to add a new site (remember to wait for the delegation to happens. if no, you can still do this step and after the delegation you can go to cloduflare and hit the “re-check dns” button) After configuring a new site you’ll have several options to configure, in this example digitalocean IP of the required server is the config we need for mail are:

Type   Name            Value               TTL     Status
A         auto    cloud-on or off
CNAME  mail        auto    coud-off*
MX  auto

*cloud-off is important, otherwise mails will be redirected to cloudflare servers

Step 3) go to your digital ocean server and follow this tutorial from “configuring postfix” step:

and that’s it. after that I send an email to an it arrived perfect to my gmail account


  • I had problems understanding what should i put on cloudflare, so i putted the config here so it will be easier for you guys
  • Mail still wasn’t arriving so i started to look at internet and this article saved me I did dig +short MX found everything was ok then i did dig +short A and found out cloudflare ip were appearing, that was because i had “cloud-on” on CNAME email, i disabled that and it worked

I hope it helps. Didn’t think this worth an article so i writting here for my fellow argentinian dudes that might need help

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business. is open-source and protect your privacy, love it!

This comment has been deleted

Dunno, but im using mailgun which is good for non-commercial stuff for me