// Tutorial //

Why You May Not Want To Run Your Own Mail Server

Published on December 11, 2014
Default avatar
By Mitchell Anicas
Developer and author at DigitalOcean.
Why You May Not Want To Run Your Own Mail Server

Introduction

When setting up a web site or application under your own domain, it is likely that you will also want a mail server to handle the domain’s incoming and outgoing email. While it is possible to run your own mail server, it is often not the best option for a variety of reasons. This guide will cover many of the reasons that you may not want to run your own mail server, and offer a few alternatives.

If you do not want to read the entire article, here is a quick summary: setting up and maintaining your own mail server is complicated and time-consuming, and there are several affordable alternatives—most people will get more value, in the form of saved time, out of using a paid mail service. With that said, read on if you want more details.

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 the the required components, 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: Postfix, Exim, and Sendmail.

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.

Examples of MDA software: Postfix and Dovecot.

IMAP and/or POP3 Server

IMAP and POP3 are protocols that are used by mail clients, i.e. any software that is used to read email, for mail retrieval. Each protocol has its own intricacies but we will highlight some key differences here.

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 provide IMAP and/or POP3 server functionality: Courier, Dovecot, 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 basically mail client that can be accessed by users via a web browser–Gmail is probably the most well-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: Roundcube and Citadel.

Maintenance is Time-Consuming

Now that you are familiar with the mail server components that you have to install and configure, let’s look at why maintenance can become overly time-consuming. There are the obvious maintenance tasks, such as continuously keeping your antivirus and spam filtering rules, and all of the mail server components up to date, but there are some other things you might have not thought of.

Staying Off Blacklists

Another challenge with maintaining a mail server is keeping 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.

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

Troubleshooting is Difficult

Although most people use email every day, it is easy to overlook the fact that it is a complex system can be difficult to troubleshoot. For example, if your sent messages are not being received, where do you start to resolve the issue? The issue could be caused by a misconfiguration in one of the many mail server components, such as a poorly tuned outgoing spam filter, or by an external problem, such as being on a blacklist.

Easy Alternatives — Mail Services

Now that you know why you probably do not want to run your own mail server, here are some alternatives. These mail services will probably meet your needs, and will allow you and your applications to send and receive email from your own domain.

This list doesn’t include every mail service; there are many out there, each with their own features and prices. Be sure to choose the one that has the features that you need, at a price that you want.

Easy Alternatives — Postfix for Outgoing Mail

If you simply need to send outgoing mail from an application on your server, you don’t need to set up a complete mail server. You can set up a simple Mail Transfer Agent (MTA) such as Postfix. A tutorial that covers this can be found here: How To Install and Setup Postfix on Ubuntu 14.04.

You then can configure your application to use sendmail, on your server, as the mail transport for its outgoing messages.

Not Convinced?

If you really want to run your own mail server, we have a few tutorials on the topic. Here are links to a few different setups:

Good luck!


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 our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.

Sign up
About the authors
Default avatar
Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?
10 Comments

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!!!