How to Setup Email on Digital Ocean

5 min


As a developer, the most important thing, is execution. In other word, getting the job done.

I started dabbling with unmanaged hosting recently, but after setting up my digital ocean instance. I was surprised that I couldn’t set up email, and there was virtually no guide online.

As such, I scoured the internet, and created an easy to follow guides, and hacks for newbie developers.

So therefore, I have outlined, some of the easiest ways to start sending emails, on a digital ocean droplet.

Three Ways to Set Up Email on Digital Ocean

That said, lets look at the three methods for setting up Emails on Digital Ocean.

Note: Some of these methods, are for WordPress hosting, not applications

A. Easiest Method (Free SMTP and Zoho) ***WordPress***

This method works for WordPress applications. It is the fastest way to start sending emails from your WordPress application.

Some people have complained that there are no images on this post, but in actuality these are the steps to follow, and it is quite easy, if you settle down, and follow the steps.

I will be updating this post appropriately in due time.

1. Sign Up to Mailgun

Mailgun is a transactional email hosting provider, that has built a robust emailing application, that can help you send lots of emails in a short amount of time.

In lay man terms, they have a wide range of ip addresses, that will guarantee your email ends up in the inbox of your user, if you set up things properly.

Don’t be stupid, as a developer, your job is to get something to work, as fast as possible, not try to build your own email sending application, when you are a startup (that is the highest level of stupidity).

In the early stages of your business, you need to focus on growth, that is where mailgun comes in, they have been in the game for years, and setting up mailgun, is not too hard, if you settle down, and learn the basics.

So head over to mailgun, and signup for an account.

2. Sign Up to Zoho Mail

Zoho offers you a free email account, to receive email, like how gmail provides a free gmail account for you.

Don’t confuse mailgun to gmail, because their services are different.

Think of your gmail account, like zoho, but the gmail app and sending of email, as mailgun. Just because they come together, and create a great user experience, doesn’t mean they arent different.

Just signup to zoho, with the email you want to use.

Note: The user interface of zoho is confusing for novices, but with time you will master it, like the WordPress dashboard.

3. Sign Up to Cloudflare

I use cloud flare for dns hosting, mostly because it is very and convenient.

But most importantly, it offers a security feature that can protect your server from online threat, and that is proxy.

If you are not using cloud flare, head over there, signup, and move your dns to cloud flare (trust me you will thank me later).

Cloudflare dns time to life is extremely fast, and a developer can make changes to their websites, and see changes in minutes, compared to domain registrars which can take days.

If you want speed, efficiency, and most importantly proxy security to hide your server ip, the cloud flare is a good choice for you.

Most importantly, because most of these features, are offered to you for free.

4. Add Zoho Dns Records

After signing up to cloud flare, and moving your dns there, you can now move to the next step.

You can still do this step, if you are adamant about being loyal to your domain registrar.

Zoho will provide you with dns records to affix to your domain.

They are an mx record, an spf record, and a dkim record.

Affix these to your domain, and test to see, whether zoho gives you a passed validation mark.

5. Verify Domain

After adding records, verify domain. These changes can take 24hrs to propagate, but if you are using cloudflare dns hosting, your records can be propagated in minutes.

How to verify your domain

  1. Add your domain or subdomain.
  2. Open your DNS provider and add the two TXT DNS records provided.
  3. If you want Mailgun to track clicks and opens you can also add the CNAME record.
  4. MX records should also be added, unless you already have MX records for your domain pointed at another email service provider (e.g. Gmail).

Once you’ve added the records and they’ve propagated, your domain will be verified.

6. Install Mailgun WordPress Plugin

The next step is to log into your WordPress dashboard and search for mailgun WordPress plugin.

Install it on your website, then we are good to go to the next step.

7. Create a mailgun SMTP

Log back in, into your mailgun, and create a sending domain.

Go back to cloudflare and create an Cname record, for that sending domain.

Go back to mailgun and create smtp credentials.

Go to your WordPress dashboard, and input the data.

8. Update your DNS Records (Very Sensitive)

Update dns records.

When inputting dns records, make sure you put the correct dns records, because improper dns records, will give you failed verification on mailgun dashboard.

9. Test Connection

Test connection in your WordPress dashboard.

The end.

B. Default Server Configuration (WordPress or One Application Server)

This method is best if you are only hosting one application or wordpress on the server.

By default, a server can send emails using postfix. You just have to edit the postfix installation, and stop emails from reaching spam folder.

To do this just follow the steps listed.

C. Use CyberPanel

Cyperpanel is a hidden jem, and like Virtualmin, is a server management panel, like cpanel, that helps you observe and manage the resources of your server.

The good thing about cyberpanel is that you don’t have to stress yourself, trying to install it.

Digital Ocean has a marketplace script that can install cyberpanel for you on your server.

Just go to Digital Ocean marketplace, select cyberpanel, and create a server with cyberpanel installed.

From there you can then

D. Install Webmin or Virtualmin

Before I forget, you cannot use this method, if you used the default one click installation package in the digital ocean app marketplace.

Virtualmin comes with many packages preinstalled, like Apache2 (I don’t know what the heck this is), postfix (SMTP), let’s encrypt and other packages.

It also gives you a graphical user interface, so you just have to SSH into your server once a month to run (or as much as you like), to run maintenance updates.

Nevertheless, if you have not migrated your website yet, you can go into your dashboard, search for the wpvivid migration plugin, in the plugins repository, and backup your site.

By following this method, the amount of time you SSH into your server, will be brought low, and with this method, you can have as many domains as you like.

E. Create your SMTP Server (To Advanced for me at the moment) Postal SMTP (Mail in a Box SMTP)

I just started dabbling with unmanaged servers 2 months ago. There is no way in the world, I can build a server right now. I know my limits, and I am not ashamed to admit them.

In the future, I will be updating this blog post, when I can safely build an SMTP server from the ground up. But until then, I will be dropping a link to the article, which will be vague to us, new programmers.

See Also:

How to Setup Email on DigitalOcean

Chmod Comman Permissions

How to Add Sudo User in Ubuntu and Linux with Root Privileges

Reference

  1. https://www.digitalocean.com/community/questions/how-to-set-up-email-on-digitalocean-droplet
  2. https://www.digitalocean.com/community/tutorials/how-to-run-your-own-mail-server-with-mail-in-a-box-on-ubuntu-14-04
  3. https://stackoverflow.com/questions/60515782/how-to-set-up-an-email-on-digitalocean-for-my-domain

0 Comments