Independent testing Updated April 2026 387 self-hosting guides 5 VPS providers tested

guide

How to Self-Host Mailu on a VPS (Complete Guide)

A complete step-by-step guide to self-hosting Mailu on a VPS in 2026, covering installation, configuration, securing Mailu, and the specs you need.

How to Self-Host Mailu on a VPS (Complete Guide)

Self-hosting your email server can be a rewarding project, and Mailu is an excellent choice for those looking to take control of their email. In this guide, we will walk you through the process of installing Mailu on a VPS, ensuring you have the required components and configuration to get started. This guide assumes you have some familiarity with Docker and basic server management.

Prerequisites

Before you begin the installation process, ensure you have:

  1. A VPS: You can choose from several providers based on your needs and budget. Hereโ€™s a quick comparison of popular VPS providers:

    ProviderPrice (EUR/USD)Key Features
    Contabo VPS5.99 EUR/monthHigh storage, intuitive management panel
    Hetzner Cloud4.15 EUR/monthAffordable, reliable performance, scalable instances
    DigitalOcean6 USD/monthUser-friendly, extensive documentation
    Vultr6 USD/monthGlobal presence, fast SSDs
    Linode5 USD/month24/7 support, easy backups

    To get started, you can use links to choose your provider: Contabo, Hetzner, DigitalOcean, Vultr, or Linode.

  2. Domain Name: You will need to register a domain name to handle your email addresses.

  3. Basic Docker Knowledge: Familiarity with Docker is necessary, as Mailu operates within containers.

Step 1: Set Up Your VPS

Once youโ€™ve chosen your VPS provider and configured your VPS, connect to your VPS using SSH. For example:

ssh root@your-vps-ip

Update Your System

Run the following commands to update and upgrade your system packages:

sudo apt update
sudo apt upgrade -y

Install Docker

Mailu runs within Docker. To install Docker, follow these steps:

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce docker-compose -y

Verify that Docker is installed correctly:

sudo docker --version

Step 2: Download Mailu

Prepare a directory for Mailu:

mkdir mailu
cd mailu

Create a new .env file in the Mailu directory. This file will contain configuration variables for your Mailu installation. Use the following command to create and open the file:

nano .env

Hereโ€™s a basic example of what the .env might look like:

# Environment settings
DOMAIN=yourdomain.com
HOSTNAMES=mail.yourdomain.com
# Other Mailu settings
SECRET_KEY=
VARIANT=master
# Add appropriate settings for SSL and admin user

Have a look at the Mailu documentation for a more in-depth configuration guide.

Step 3: Deploy Mailu on Docker

With the necessary configurations complete, letโ€™s create the necessary Docker containers for Mailu. You can do this using Docker Compose. Create a docker-compose.yml file:

nano docker-compose.yml

Add the basic Mailu stack configuration:

version: '3'

services:
  front:
    image: mailu/nginx
    restart: always
    env_file: .env
    volumes:
      - mailu-vmail:/data
      - mailu-ssl:/certs
    networks:
      mailu:
        aliases:
          - mail

  smtp:
    image: mailu/postfix
    restart: always
    env_file: .env
    networks:
      mailu:

# ... Add other services like imap, webmail, etc.

Run the following command to launch your Mailu stack:

sudo docker-compose up -d

You can verify that the containers are running with:

sudo docker ps

Step 4: Finalize the Setup

Now that you have Mailu running, configure your DNS records to point to your VPS. Youโ€™ll want to set up MX records for your domain that points to your Mailu instance.

Example DNS Configuration

These DNS changes might take a while to propagate.

FAQs

What is Mailu?

Mailu is a simple, yet full-featured email server solution that runs on Docker and gives you control over email hosting. It can handle multiple domains and comes with built-in features such as webmail, spam filtering, and storage management. By self-hosting Mailu, you can enjoy a personal email hosting experience tailored to your needs.

Can I scale my Mailu installation?

Yes, Mailu is designed to scale. Using Docker means you can easily add more resources or containers as your userbase grows. You can also use load balancers to distribute traffic among multiple instances if needed. Depending on your VPS providerโ€™s offerings, scaling can be relatively straightforwardโ€”just ensure you monitor performance and resource usage over time.

Is self-hosting my email secure?

Self-hosting your email can be secure if configured correctly. Youโ€™ll want to enable SSL/TLS for your connections, ensure strong passwords are used, and regularly update your Docker containers to patch any vulnerabilities. While self-hosting gives you control, it also requires diligence regarding security practices. Be sure to regularly consult resources like r/selfhosted or awesome-selfhosted for the latest in self-hosted solutions and security best practices.

For a full VPS comparison, check our site. Happy self-hosting!