I’ve recently started migrating all of our name server management over to Cloudflare. Cloudflare, in case you don’t know, provide a free CDN which means your WordPress sites become far faster and far more scalable. By using Cloudflare to serve up your images, .js files, .css files and .xml files you leave your WordPress server with far fewer connections to manage, far less data to pump through its network card and far less work to do.
In order to set up Cloudflare, you have to transfer management of your DNS over to them so Cloudflare becomes your name server. This is fine if you have your own mail server set up, but if – like me – you often set up mail forwarding (e.g. using GoDaddy, they offer free mail forwarding to my gmail account) then you’re going to need to configure a mailbox somewhere.
There are 2 problems you need to solve – firstly, you need to solve forwarding your mail, which means you need a mail server so you can alter the DNS on CloudFlare to point at it – that will mean this mail server will then forward mail to your gmail account. I’ve chosen Mailgun to handle forwarding my mail as per the image below:
Secondly, you need an SMTP server – gmail recently removed the ability to send emails through their own servers – presumably due to spamming/capacity issues. To set up an SMTP server, you can use MandrillApp (which I highly recommend – owned by MailChimp so they know how to send emails) or Mailgun which is owned by Rackspace. Since I’m using Mailgun as an MX server, I’m going to skip setting up two servers and just use them for SMTP too.
Transferring Name Servers to Cloudflare
This step is fairly trivial – sign up to CloudFlare then click to add a new website and enter your domain name. CloudFlare will scan your existing domain records and import them to its own name servers. Now you can make the switch seamlessly.
Log onto your domain name registrar and transfer the name servers over to CloudFlare. This can take up to 24 hours but typically happens within a few minutes.
Setting up Mailgun to receive and forward email
Sign up for a Mailgun account then add your domain name. As part of the setup process they ask you to set up your MX records which you should do on Cloudflare. They also ask you to add an additional couple of txt records which will vastly improve deliverability of your emails. Once your MX records and TXT records are set up, go back to Mailgun and click on ‘Routes’ to set up the routing rules. Basically you set up a rule for each email address to match the destination email and then enter the forwarding rule to forward it to Gmail. Once you’ve completed
Setting up Gmail to send email through Mailgun
Mailgun is a fantastic product, with great additions for developers to allow you to programatically add email addresses and manage your marketing and transactional emails, but in this case we’re just setting up Mailgun as an SMTP server with Gmail.
Log in to Gmail, click the cogwheel on the top right (settings) then click ‘Account’. If you already have the account for your domain, then click to edit it otherwise click to add a new account.
To access your SMTP details, from Mailgun click through to Domains then click on the domain your setting up. Your SMTP server, username and password will be listed. Mailgun listens through all ports and uses both SSL and TLS – for email, there is no difference in security level, but choose TLS anyway as this is more secure for websites (no difference for email) and because of this will be around longer in the future.
If the above is too technically challenging, we are currently offering to set up CloudFlare for you.
- My WordPress performance plugins and server stack have moved - July 31, 2016
- Price Comparison Pro 1.2 Released - July 5, 2016
- How to run backups on huge WordPress websites without your website being brought offline - February 4, 2016