How to Setup a Mail Server on Debian Using Mailu and Send Bulk Emails TodayMailu is a simple yet full-featured mail server as a set of Docker images. It is easy to deploy and manage, making it an ideal choice for those looking to set up a mail server with minimal hassle.

It’s also an email server that uses Docker like Docker Mailserver and mailcow. What’s best is this is a free and open-source mail server stack.

Today, I will guide you on how to setup a mail server on Debian using Mailu, covering everything from prerequisites to troubleshooting.


Before you begin, ensure you have the following:

  1. A VPS or Dedicated Server: A machine with a clean installation of a Linux-based operating system (Debian, Ubuntu, or CentOS recommended). I recommend RackNerd or UltaHost.
  2. A Domain Name: You will need a registered domain name on Namecheap or other domain registrars.
  3. Docker and Docker Compose: Installed on your server. You can follow the official Docker documentation for installation instructions.
  4. Basic Knowledge of Linux Command Line: Familiarity with basic commands and file editing in Linux.

How to Setup a Mail Server on Debian Using Mailu

Step 1. Get a VPS

Buy a VPS on RackNerd or UltaHost. We’ll use a VPS that doesn’t block port 25.

If you want to use RackNerd, choose LA or France locations. We will be using Debian 12 to install Mailu.

RackNerd KVM VPS for Email Hosting

Once your VPS is activated, check your IP on MXToolBox.

0 Blacklist IP RackNerd

After that, get a free IPv6 by contacting their support.

Step 2: Get a Domain Name

Go to Namecheap and register your domain there.

Buy a Domain on Namecheap Web Shanks

Step 3: Setup Initial DNS, rDNS and Hostname

Go to your control panel and set your hostname. I’ll set it to

Set a Hostname RackNerd

Then open a ticket on RackNerd and let them know that you want to set rDNS for both IPv4 and IPv6 to Be sure to put your own domain.

Step 4: Connect to Your Server

Download and run a free SSH client like Bitvise.

Bitvise RackNerd

For advanced users, instead of using password-based authentication, you might want to switch to SSH keys authentication.

This enhances your server security.

Bitvise New terminal console

Start by updating your server to ensure all packages are up-to-date:

For root:

apt update && apt upgrade -y && apt -y install curl wget sudo

For non-root with sudo privileges:

sudo apt update && sudo apt upgrade -y

If you haven’t installed Docker and Docker Compose yet, you can do so by running:

# Install Docker
curl -fsSL -o
sudo sh

# Install Docker Compose
sudo curl -L "$(curl -s | grep tag_name | cut -d '"' -f 4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

You can also find a detailed guide to installing Docker here.

Step 5: Install Mailu

Create a directory for Mailu configuration files:

mkdir -p /mailu && cd /mailu

Now let’s use this super handy setup utility by Mailu.

Let’s break down this part step by step.

Step 1 – Initial configuration:

  • Mailu storage path: /mailu
  • Main mail domain and server display name: (your domain).
  • Postmaster local part: admin
  • Choose how you wish to handle security TLS certificates: letsencrypt
  • Website name: Web Shanks (your preferred name).
  • Linked Website URL:
  • Enable the admin UI: yes

Step 1 - Initial configuration Mailu

Step 2 – Pick some features:

  • Enable Web email client: roundcube
  • Enable the antivirus service: yes
  • Enable the webdav service: yes
  • Enable fetchmail: yes
  • Enable oletools: yes
  • Enable Tika: yes

Step 2 - Pick some features Mailu

Step 3 – expose Mailu to the world:

  • IPv4 listen address: your IPv4
  • Enable an internal DNS resolver (unbound): yes

Step 3 - expose Mailu to the world

Mailu configuration – Your configuration was generated

Finally, you will use this configuration in installing Mailu.

Mailu configuration - Your configuration was generated

Step 6: Access the Admin Interface

Once Mailu is running, you can access the admin interface to manage your mail server:

Log in with the default admin credentials you set. From here, you can create email accounts, aliases, and manage your server.

Mailu Login Interface

Step 7: Setup DNS Records

Now, let’s setup our DNS records.

Go to Mail Domains and choose the domain you want to set DNS records with.

Domain List Config

We will need to set this to our DNS provider.

Domain DNS Records Mailu

I’ll be using a free Cloudflare account.

We will add Cloudflare’s nameservers to Namecheap.

Cloudflare Namecheap Nameserver

We will map Mailu DNS records to our Cloudflare.

Cloudflare Mailu

Step 8: Test Email Deliverability

Finally, we can test our email deliverability.

Let’s send a test email to Mail-Tester.

But first, we will add a user.

Go to Mail Domains > Click the Envelop Icon.

Create New User Mailu

Add New Email Mailu

Login using the newly created account.

Let’s send a test email to Mail-Tester.

Mailu Send Test Email

We got a perfect score!

10-10 Score in Mail-Tester Mailu

Now let’s try to send an email to Gmail.

We received it directly in our inbox!

Mailu Send Test Email to Gmail

Let’s reply if we can receive it in our Mailu webmail.

And we got the reply!

Mailu Received a Reply from Gmail

Now we can send and receive email messages using the Mailu mail server.


What ports need to be open for Mailu to work?

Ensure the following ports are open on your firewall: 25 (SMTP), 80 (HTTP), 443 (HTTPS), 110 (POP3), 995 (POP3S), 143 (IMAP), 993 (IMAPS).

How do I back up my Mailu server?

You can back up your Mailu server by creating backups of the Docker volumes used by Mailu. Use the docker-compose commands to stop the services, back up the volumes, and then restart the services.

How do I update Mailu?

To update Mailu, pull the latest Docker images and recreate the containers:

docker compose pull && docker compose up -d


Issue: Cannot receive emails

  • Ensure your MX records are correctly set.
  • Verify that your server’s firewall is not blocking port 25.
  • Check the Mailu logs for any error messages.

Issue: Cannot send emails

  • Verify your SMTP settings.
  • Ensure your SPF, DKIM, and DMARC records are correctly configured.
  • Check the Mailu logs for any error messages.

Issue: Admin interface is not accessible

Ensure the Mailu containers are running.

docker compose down && docker compose up -d


By following my guide, you should have a functional mail server that can send and receive emails securely.

Remember to keep your server and Mailu up-to-date to ensure security and performance.

If you encounter any issues, refer to the Mailu documentation and community for additional support.

Happy emailing!


  1. thanks bro! i have some problem, the mail server working well, but too many spam mail everyday, can i setup some spam filter rules for my hosted mail server?

Leave a Reply

Your email address will not be published. Required fields are marked *