Tutorial

Why You May Not Want To Run Your Own Mail Server

Updated on July 4, 2022
Why You May Not Want To Run Your Own Mail Server

Introduction

When setting up a web site or application under your own domain, your hosting provider may also offer you the option of configuring your own mail server. Although there are many robust open source solutions such as Dovecot, hosting your own mail is often not the best option for many deployments. Because of the relatively complicated way that DNS records, spam filters, and webmail interfaces are implemented, maintaining your own mail server is becoming less popular, and less widely supported by hosting providers. Most people will get more value out of using a hosted mail service. This guide will cover many of the reasons that you may not want to run your own mail server, and offer a few alternatives.

Mail Servers Are Complex

A typical mail server consists of many software components that provide a specific function. Each component must be configured and tuned to work nicely together and provide a fully-functioning mail server. Because they have so many moving parts, mail servers can become complex and difficult to set up.

Here is a list of required components in a mail server:

  • Mail Transfer Agent
  • Mail Delivery Agent
  • IMAP and/or POP3 Server

In addition to those, you will probably want to add these components:

  • Spam Filter
  • Antivirus
  • Webmail

While some software packages include the functionality of multiple components, the choice of each component is often left up to you. In addition to the software components, mail servers need a domain name, the appropriate DNS records, and an SSL certificate.

Let’s take a look at each component in more detail.

Mail Transfer Agent

A Mail Transfer Agent (MTA), which handles Simple Mail Transfer Protocol (SMTP) traffic, has two responsibilities:

  1. To send mail from your users to an external MTA (another mail server)
  2. To receive mail from an external MTA

Examples of MTA software include Postfix, Exim, and Sendmail.

Note: As a general rule, even if you are committed to not running a full mail server, an MTA is still relatively straightforward to deploy on its own in order to send alerts or notifications from your software. This is sometimes challenging because some hosting providers (including DigitalOcean) will automatically block the default outgoing mail port, 25, in order to avoid being used for spam. To avoid this, you can use a third-party SMTP server. You can also review How To Install and Setup Postfix.

Mail Delivery Agent

A Mail Delivery Agent (MDA), which is sometimes referred to as the Local Delivery Agent (LDA), retrieves mail from a MTA and places it in the appropriate mail user’s mailbox.

There are a variety of mailbox formats, such as mbox and Maildir. Each MDA supports specific mailbox formats. The choice of mailbox format determines how the messages are actually stored on the mail server which, in turn, affects disk usage and mailbox access performance, as well as import/export compatibility.

Examples of MDA software include Postfix and Dovecot.

IMAP and/or POP3 Server

IMAP and POP3 are protocols that are used by mail clients — software that is used to read email, for mail retrieval.

IMAP is the more complex protocol that allows, among other things, multiple clients to connect to an individual mailbox simultaneously. The email messages are copied to the client, and the original message is left on the mail server.

POP3 is simpler, and moves email messages to the mail client’s computer, typically the user’s local computer, by default.

Examples of software that provides IMAP and/or POP3 server functionality include Courier, Dovecot, and Zimbra.

Spam Filter

The purpose of a spam filter is to reduce the amount of incoming spam, or junk mail, that reaches user’s mailboxes. Spam filters accomplish this by applying spam detection rules — which consider a variety of factors such as the server that sent the message, the message content, and so forth — to incoming mail. If a message’s “spam level” reaches a certain threshold, it is marked and treated as spam.

Spam filters can also be applied to outgoing mail. This can be useful if a user’s mail account is compromised, to reduce the amount of spam that can be sent using your mail server.

SpamAssassin is a popular open source spam filter.

Antivirus

Antivirus is used to detect viruses, trojans, malware, and other threats in incoming and outgoing mail. ClamAV is a popular open source antivirus engine.

Webmail

Many users expect their email service to provide webmail access. Webmail, in the context of running a mail server, is a mail client that can be accessed by users via a web browser. Gmail is probably the best-known example of this. The webmail component, which requires a web server such as Nginx or Apache, can run on the mail server itself.

Examples of software that provide webmail functionality include Roundcube and Citadel.

Downsides to Running a Mail Server

Although having to maintain a stack of four or five different software components in order to provide basic functionality is not ideal, it may not seem so much worse than other deployments in that regard. This, however, does not take into account the significant “trust” issues of running your own mail server.

In many ways, mail server stacks represent a collision between the tools and values of the early internet — self-hosting open source software using well-defined standards and interoperable protocols — and the reality of the modern internet — a few centralized, trusted authorities. More than web servers, database servers, or other cloud software, they have to handle an enormous amount of untrustworthy input, and the trust standards of commercial mail servers are very high as a result. Because mail servers are constantly handling attachments of potentially harmful files, and constantly filtering spam and spam addresses, it can be quite challenging to run a server that actually keeps up with the expectations of modern webmail providers. Many of them will not hesitate to block traffic from a temporarily compromised sender, especially if it is a small, self-hosted operation.

Staying Off Blacklists

It is not trivial to keep your server off of the various blacklists, also known as DNSBL, blocklists, or blackhole lists. These lists contain the IP addresses of mail servers that were reported to send spam or junk mail (or for having improperly configured DNS records). Many mail servers subscribe to one or more of these blacklists, and filter incoming messages based on whether the mail server that sent the messages is on the list(s). If your mail server gets listed, your outgoing messages may be filtered and discarded before they reach their intended recipients.

When deploying a web server, it is fairly common to experience occasional outages from DNS misconfiguration. There is a substantial ecosystem of CDNs and load balancers whose primary purpose is to prevent these minor outages from otherwise impacting your infrastructure. When it comes to mail servers, however, a minor misconfiguration can make it hard to — literally — restore trust.

If your mail server gets blacklisted, it is often possible to get it unlisted (or removed from the blacklist). You will need to determine the reason for being blacklisted, and resolve the issue. After this, you will need to look up the blacklist removal process for the particular list that your mail server is on, and follow it.

Hosted Mail Services

Hosted mail services fall into two broad categories. The first category is comprised of personal webmail providers. These service providers are widely known for their free service tiers, and usually provide paid options for hosting a custom email domain, supporting multiple users of a shared business account, and so on. They usually provide their own webmail interfaces and dedicated mobile apps.

A second category is mail delivery services. These providers are not necessarily in the personal email business, but instead provide API access for any software that needs to send mail in bulk, such as password change notifications or advertising campaigns. Usually, these services include dedicated mail server credentials, the relevant trust and filtering features, and a web dashboard to monitor your mail volume and any related issues. They are typically priced by usage.

This list is not exhaustive, but should provide an overview of the service landscape.

Conclusion

Although email is a fundamental internet technology, many cloud providers are reluctant to support self-hosted mail servers because of their inherent challenges. We generally recommend using an external provider to handle email for your cloud.

If you are determined to run your own mail server, you can see a comprehensive example in How To Configure a Mail Server Using Postfix, Dovecot, MySQL, and SpamAssasin.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


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!

I run my own mail server(s) without any issues and whenever there’s an issue, it’s just “fun” to fix it :]

There is also https://mailinabox.email/, a project I started to deploy a working mail server without the need (or even the possibility) to configure the system. It’s like an email appliance. It doesn’t solve all of the issues of running your own mail server, but it does solve a lot.

I am going to have to disagree. You can easily run your own mail-server, I do it for 150 people at work and yeah I am the solo IT guy. I spend 1 minute a day on average just making sure there’s nothing funky in log files…

There is however a giant learning curve. If you aren’t afraid of learning how email works then you have no problem at all. There are plenty of tutorials to follow. Also running your own mail server is the only scalable option… places that do hosted email often are $2/mailbox… for 150 that is $300/mo… Our server runs off of a $20 instance… Huge cost savings for a bit of work.

This is not a tutorial.

I’m using iRedMail as mailserver soulution and i’m pretty satisfied with it. Of couse, hosting your own mailserver is nothing for you if you do not have any idea how to handle it. But you can say this for everthing. I can also write an acticle thats called “Why You Should Not Run Your Own Web Server” or “Why You Should Not Run Your Own XYZ Server”.

If you let anything do others for you, you’ll learn absolutly nothing, and in my option thats the wrong way. Digital Ocean brings you a perfect platform to do what you want, try things out, and if it’s not working … jump back to a clean, fresh installed system, reachable from all over the world, and not only in your private home network.

So, thanks, Mitchell, for your tutorial, but please all of you try things out and learn how it works!

j2c skydriver

If you don’t want to run an email server, you can use an email forward service such as mailgun to create any email@yourdomain.com you want and redirect them to your own gmail/hotmail inbox. Once authorized via SMTP, you will be able to send/receive emails securely under your email@yourdomain.com via gmail.

Check out this guide to learn how to configure mailgun and your domain DNS for your own email addresses @yourdomain.com. It’s pretty simple and free versus setting up an email server.

Now for the reasons you would want to setup your own:

  • You maintain your privacy, if you can pull off setting one up. Yes, I’m sure stuff is scooping all the e-mails up that go over the internet anyway, on the backbones, but you won’t be having your stuff read by bots for targeted advertising. And even then, if you transmit over SSL, less of a chance of things getting it off of the backbones.
  • You maintain control, the server is yours or a VPS you’re paying for.
  • You can use as many domains as you want, and give out as many e-mails if you want to friends, have encrypted mailboxes, SSL certs, etc without paying for something like Google Apps or Outlook 365
  • It’s educational: Personally I think it’s great for people to learn how this stuff works. That’s one of the main issues with the internet today: No one (excluding techs and IT, and even then a lot of them have no clue), including the people making laws on it here in the US, understand how anything on it works or why it works.

I’m not saying office 365/google apps/gmail/etc is bad, to each their own, but I think it’s very beneficial and wise to learn how this stuff works and exactly what you’re getting into by using it. I even use Google Apps currently because that’s what we had for an old business I was apart of, and at work we use Office 365, it’s a huge timesaver in places like this. But personally? I’m switching off google apps (since the business doesn’t do anything, and it’s just two of us), and setting up my own here pretty soon.

After trying it out for myself and reading this article, I couldn’t agree more. Yes, it might be fun and so on, but if you’re not doing it seriously (company, emplayees etc). Otherwise I would strongly recommend using already built and managed systems, because it can get a mess and very sensitive data can be lost, corrupted. And actually after checking service providers, prices and options, simply I can’t find any other solution than going back to godaddy, because it just beats the price and offers. Although I hate service and that I can’t have my hands on everything as I could on DO, but…

I’ve used alot of your tutorials and usually love them, but with this i highly disagree, how about why telling people why they shouldn’t be using centralised services like gmail and why they should be using their own mail server

I would also just like to add that while mail servers can be very complex and confusing, there are also very simple options available. Options that you can complete in just a few minutes and have your own mail server up and running with full root access and all traffic encrypted. I will show you how in 11 (some are not required, like the Enjoy step: ) steps that can be done within an hour!

For example, determine if you think to you could complete the tasks below:

  1. Rent a digitalocean box for 5 bucks a month.
  2. Spin up a Ubuntu Server droplet (latest edition or whatever you like).
  3. After you have a user for yourself with sudo (root privileges), type sudo apt-get update, followed by sudo apt-get upgrade.
  4. At this point, make sure you have a domain purchased that you would like to use, or me, it would be pax(linux user you created)@myexampledomain.com(your domain, or IP.
  5. When that is complete and you have a user with sudo ability, say mine is called pax. Type sudo apt-get install mail-stack-delivery, wait for installation to complete, fill in setup instructions on screen.
  6. Reboot.
  7. Download Thunderbird and create a custom mail account using the email above (linux user@domain.com)
  8. You now have your own, super awesome, encrypted mail server ready for use. Send some test emails now!
  9. Finally if you want to add friends, family, or anyone to use your mail server, just create them a linux user, let them set the password, or set it for them and allow them to change it.
  10. The last thing is to make sure you delete your old, slow data sized Gmail, Yahoo, or other account, get your dignity and respect back with no help from Google!
  11. Enjoy

Post instructions opinion:

I do not like the fact that the top result for setting up a mail server, discourages people from trying, because it is too hard, and not worth it. Isn’t that why we use Digital Ocean, so we can learn, develop, and create stuff on our own root access server. Seems counter productive to me.

I have learned so much from installing more complex programs on my linux server box. It is incredibly satisfying when done, and I had a really fun time learning how to do it.

Don’t be discouraged, you can do it!!!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more