Are you looking for a simple but thorough guide on how to set up a Ubuntu Mail Server? Look no further!

Dive into our step-by-step guide on ‘How to Install Ubuntu Mail Server‘ and unlock the secrets to mastering your own email server today!

In this post we will walk you through the steps of installing and configuring Mailcow, a very popular email server for sending and receiving emails.

But first, let’s learn a little bit about Mailcow.

Mailcow Email Server logo

What is the Mailcow Email Server?

Mailcow is an open-source email server solution that makes setting up email services on Linux a breeze. It’s specifically designed for running inside containerized servers, integrating key components such as a mail transfer agent, a webmail client, and security features – all into one single system.

Mailcow is essentially a collection of Docker containers that run various mail server applications, including (but not limited to) SOGo, Postfix, and Dovecot. Each container represents a single application – and they are all connected in a bridged network.

It offers a modern and user-friendly web interface, known as the Mailcow UI, which provides a simple and easy interface for configuring nearly all settings and administrative tasks, such as enabling the easy creation of new domains and email addresses with just a few clicks.

All the data, such as emails and user data, is stored in Docker volumes. This setup makes Mailcow a robust and straightforward choice for those seeking a self-hosted email server solution.

How to Install SMTP Email Server in Ubuntu

Here are the step-by-step instructions for installing the Mailcow email server on a Linux server:


If you don’t plan on sending too many emails, then you’re better off using a third-party email service as it’s generally cheaper than maintaining and running a private email server. We’ve already covered the topic of using third-party email servers in extensive detail in our previous posts, which you can jump to here:

  1. Using Mailgun To Send Transactional Email From WordPress
  2. How to Send Email from PHP (With Guided Walkthrough)
  3. 15 Best Email Hosting For Small Business (2024)
  4. The 19 Best & Most Reliable Transactional Email Services 2023

If you are determined to set-up your own email server, we recommend installing it on a separate VPS from your websites. By doing it this way, if someone hacks into your website, they won’t be able to gain access to your emails and user data.

As we’ve mentioned, we will be using Mailcow as our email server, so begin by making sure your machine meets the following minimum requirements so that the installation process goes smoothly:

  1. CPU: 1 GHz
  2. RAM: Minimum 6 GiB + 1 GiB swap (default config)
  3. Boot Disk: 20 GiB (without emails)
  4. Architecture: x86_64, ARM64

You can provision your server from any cloud provider that meets these requirements. In this tutorial, we will be using a Ubuntu 22 instance on Hetzner. Once your machine is up and running, you need to log in to your server via the command line and install Docker.

Some providers may block outgoing ports to prevent spam, so make sure you configure your firewall settings to allow incoming TCP connections on all of the following ports: 25, 465, 587, 143, 993, 110, 995, 4190, 80, and 443.

On Hetzner, you’ll need to submit a special request to unblock port 25 and 465 by going to your server settings and switching to the networking tab. On this screen, you will see a button labeled ‘Request Unblocking Ports’.

When you click on the ‘Request Unblocking Ports’ button, you will see a dialog box which will require you to justify the need for this action. In the provided textbox, explain why you need an email server and submit the request – most requests are automatically approved within a minute.

Dashboard Domain Setup

Once you have a server up and running, it’s time to set up your DNS records. Although this action can be left until later, we recommend doing this first because DNS propagation takes time.

Go to your DNS registrar’s dashboard and add the relevant A/AAAA records for the dashboard of your email server to point this domain to your machine. After setting up the mail server, your users will need to visit this website to send and read emails.

Note: This domain can either be a completely separate fully-qualified domain name, or it can be a subdomain of your existing domain – it doesn’t matter.

If you’re using RunCloud, you can easily set up and configure your DNS records using the DNS manager right from your RunCloud dashboard.

setting up domain name in RunCloud

Suggested Read: How To Speed Up DNS Propagation | Ultimate Guide 

Mailcow Installation

Log in to your server with root privileges and start the process of installing Mailcow by running the following commands:

cd /opt
git clone
cd /opt/mailcow-dockerized

The above commands will download and store the necessary files for starting the installation on your server. If you executed the above commands correctly, the command line will prompt you to enter the domain name that you configured in the previous step. After entering the domain name, you will be asked to specify some basic settings such as timezone and the development branch.

Enter your timezone, or just press ‘Enter’ to use the default settings. Next, press ‘1’ to use the stable version and then press ‘Enter’ – this will download the necessary files for starting the installation. Finally, execute the following commands to download and run the docker containers:

docker compose pull
docker compose up -d
Installing Mailcow Email Server in Ubuntu

After executing the above Docker commands, you will see that all the necessary containers have been started.

Dashboard Setup

Once your Docker containers are up and running, you can visit your Mailcow dashboard main page in your browser using the domain name that you specified earlier. On this screen, you will see a login page for the default admin account – the admin credentials are admin and moohoo.


When you log in to your dashboard for the first time, you will see a statistics page for your server that shows basic diagnostic information such as CPU usage, memory usage, and all the currently running services.

Inbox Domain Setup

In your Mailcow dashboard, you can now start adding different domain names for your email inboxes. Click on the Email dropdown and select Configuration. In the domains tab, you can click on “Add domain” and follow the instructions on screen to set it up.

After filling in all the information, you will be asked to configure the DNS records for this domain. Go to your DNS registrar’s dashboard and create all the required records using the values provided by Mailcow.

Setting up these DNS records correctly is necessary for sending and receiving emails via your mail server. Read our post titled DKIM – What Is It & Why Your Emails Need It to understand this better.

User Setup

After adding an inbox domain to your mail server, you can start using it immediately by creating new user accounts. Switch to the users tab and click on “Add User” to create a new account.

On the next screen, you can fill in your username, full name, a login password, and configure other email settings such as the rate limit or the protocol that can be used to access your email address.

Webmail Setup

After adding users to your server, you can open your SOGo dashboard by clicking on the Apps > Webmail. Once you click on Webmail, it will show you a login form, where you can enter the email address and password that you just created.

Once you log in to your email account, you can start using it to send and receive emails normally.

Wrapping Up

Setting up an email server on Ubuntu can be a complex task, but with the right tools and guidance it becomes entirely manageable. We’ve walked through the process of installing a Mailcow email server, which offers a robust and straightforward solution for those seeking a self-hosted email server.

However, it’s important to note that if you’re planning to send fewer emails, using a third-party email service might be a more efficient and cost-effective solution. These services often provide better deliverability, simplified scalability, and dedicated support – which can save you a lot of time and effort in the long run.

Lastly, for managing and deploying web applications to the cloud, we highly recommend using RunCloud. It’s a powerful and user-friendly platform that simplifies the process of managing, configuring, and deploying applications, making it an excellent tool for developers of all skill levels.

Sign up for RunCloud today!

FAQ on Ubuntu Mail Server

Does Ubuntu have a mail server?

Ubuntu does not have a mail server of its own, but it supports several mail servers, such as Postfix, Sendmail, and Exim.

How to create an SMTP server in Ubuntu?

To create an SMTP server in Ubuntu, you can install Postfix, which is a popular and powerful SMTP server. Here are the steps:
Update your package list using sudo apt-get update.
Install Postfix using sudo apt-get install postfix.
During the installation, a prompt will appear asking for the type of mail configuration. Select ‘Internet Site’.
Enter the fully qualified domain name (FQDN) for your server.
Once the installation is complete, you can edit the configuration file located at /etc/postfix/ as per your requirements.

How to set up Sendmail in Ubuntu?

Setting up Sendmail in Ubuntu involves a few steps:
Install Sendmail using sudo apt-get install sendmail.
Configure /etc/mail/ by defining SMART_HOST.
Run make in /etc/mail to implement the changes.
Restart the Sendmail service with sudo service sendmail restart.

What is the difference between Ubuntu and CentOS mail servers?

The primary difference lies in the package management and the associated configurations. Ubuntu uses apt for package management, while CentOS uses yum. Therefore, the installation and configuration commands will differ. However, both can run the same mail servers such as Postfix or Sendmail.

Why do I need a mail server in Linux?

A mail server in Linux allows you to control your mail data, apply extensive customizations, integrate with other applications in your environment, and more. It’s particularly useful for businesses that require extensive control over their email.

What is the default Linux mail server?

There isn’t a default mail server for all Linux distributions.

Should you use Sendmail or Postfix?

Both Sendmail and Postfix are robust and reliable mail servers. Postfix is often favored for its ease of configuration and better security track record. However, some might prefer Sendmail because of its wide usage and extensive online resources.

How do I run a local SMTP server?

To run a local SMTP server, you can use tools such as Postfix or Sendmail. After installing them, you need to configure the mail server to run on your local machine, usually by setting the inet_interfaces parameter to localhost in the configuration file.