Make a Free Email Server with Multiple Domains Using aaPanel, RackNerd and CloudflareHosting multiple email accounts and domains efficiently is a crucial task for any organization.

Today I’ll show you how to make a free email server with multiple domains using aaPanel, RackNerd, and Cloudflare. I’ve written a guide using this method but for only a single domain. Check it out here.

This article will guide you through the systematic steps of setting up and managing multiple emails and domains using aaPanel on an Ubuntu 22.04 server.


Before diving into the setup process, ensure you have the following prerequisites in place:

  1. Ubuntu 22.04 Server: A freshly installed Ubuntu 22.04 server with root access on RackNerd VPS.
  2. Domain Names: Registered domain names that you plan to manage using the server. Buy your domains on Namecheap.
  3. Basic Linux Knowledge: Familiarity with Linux command-line operations.

Make a Free Email Server with Multiple Domains Using aaPanel, RackNerd and Cloudflare

aaPanel provides a user-friendly interface that simplifies server management tasks, including web hosting, email server configuration, and domain management.

Let’s start!

Step 1: Get a VPS on RackNerd

Go to RackNerd and get at least 2GB VPS. Follow these steps on how you can setup RackNerd VPS.

Why RackNerd? Because it has an open port 25. We need this port to send emails. You can also choose Contabo.

RackNerd KVM VPS for Email Hosting

Once your VPS is ready, check your IP for any blacklist.

0 Blacklist IP RackNerd

Then ask for an IPv6 to enhance your email deliverability. You need to contact RackNerd support to do this. It’s free!

Step 2: Get a Domain

Now we need a domain. Go to Namecheap and register your domain. Avoid .work .date .top .fun .life .review .xyz .bid .stream .site .space .gdn .click .pro top-level domains.

Buy a Domain on Namecheap Web Shanks

Create a free Cloudflare account and add a website.

Then add its nameservers to Namecheap.

Cloudflare Nameservers
Copy these nameservers to Namecheap.
Cloudflare Namecheap Nameserver
Use custom DNS to be able to use Cloudflare’s nameservers.

Step 3: Setup Hostname, Initial DNS and rDNS

In your VPS control panel, go to the Hostname tab and change your hostname to or you can change it on the command line.

nano /etc/hostname

Set the hostname for IPv4 and IPv6.

nano /etc/hosts

Hostname for aaPanel

RackNerd handles rDNS. You need to open a ticket and set your rDNS to the same as your hostname.

Request to Change rDNS

Step 4: Connect to your Server

Download and install Bitvise – it’s a free SSH client.

Bitvise RackNerd

Bitvise New terminal console

Step 5: Install aaPanel

Begin by updating your system’s package list and upgrading the installed packages:

sudo apt update && sudo apt upgrade -y

Download and install aaPanel using the following commands:

URL= && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O "$URL";fi;bash aapanel

If you want to install aaPanel in /www directory just choose Y.

Do you want to install aaPanel to the /www directory now?(y/n): y

Install aaPanel Ubuntu 22.04

If successfully installed, you will see this message.

Note down the login URL, username, and password provided at the end of the installation.

aaPanel Successfully Installed

Be sure to enable IPv6 on /etc/sysctl.conf file. The default IPv6 is disabled.

nano /etc/sysctl.conf

The values should be set to 0.

net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0

Reboot your server.


Open a web browser and navigate to the aaPanel login URL. Use the provided credentials to log in to the panel.

Access aaPanel Ubuntu 22.04

Enter the login details given to you after installation.

Login aaPanel

Once you’re logged in, install important software packages. You can follow my selection. I’m using the latest version as much as possible.

aaPanel Software Packages Selection
If the task takes long or lags, you can restart the panel on the top right menu.

Before we add domains and emails, we need to use a secure URL to access our aaPanel.

First, add an A record for the domain panel, for example, on Cloudflare.

Next, go to Settings > Security > Domain.

Be sure that Panel SSL is toggled on. Click Save.

Set aaPanel Domain for Panel Access
You will get a ‘The domain name access has been opened, and I cannot access it through IP, please re -enter’ error on your browser but it’s normal. You will need to login using your panel address.

This is the format of your new panel login address:

In my case, it will be:

Then hit Click to jump.

The domain name access has been opened, and I cannot access it through IP, please re -enter

In this part, you will see a Warning: Potential Security Risk Ahead. The panel SSL is not yet activated. Just proceed to Accept the Risk and Continue.

Now we will use a free SSL from Zero SSL.

Signup with ZeroSSL.


Create a new certificate.

Enter the domain name(s) you want the certificate for. If you’re ordering a Multi-Domain certificate, you can add multiple domains. Click Next.

ZeroSSL New Certificate

ZeroSSL Enter Domain

Choose the validity period for the certificate (e.g., 90 days, 1 year). Note that the free certificates are typically for 90 days. Click Next.

ZeroSSL Validity

Choose whether you want ZeroSSL to generate the CSR (Certificate Signing Request) for you or if you want to upload your own CSR.

Then just choose the free plan.

ZeroSSL Finalize Order

Choose a method to verify your domain ownership. The available methods are:

  • Email Verification: An email will be sent to a domain-related email address (e.g., [email protected]) with a verification link.
  • DNS (CNAME) Verification: You’ll need to add a CNAME record to your domain’s DNS settings.
  • HTTP File Upload: You’ll need to upload a specific file to your website’s root directory.

We will be using DNS Verification. We will add a CNAME on Cloudflare.

ZeroSSL Domain Verification

Copy the Name and Point To it on Cloudflare.

ZeroSSL Cloudflare CNAME Verification

Follow the instructions provided to complete the verification process for your chosen method. Once verified, you can proceed.

ZeroSSL Verify Domain

Once your domain is verified, ZeroSSL will issue your certificate.

Download the certificate files, which typically include:

  1. The SSL certificate (certificate.crt)
  2. The CA bundle (ca_bundle.crt)
  3. The private key (if you generated the CSR with ZeroSSL)

ZeroSSL Install Certificate

Open certificate.crt and private.key using Notepad.

ZeroSSL Certificate files

Now go back to your aaPanel control panel and go to Settings > Security > Panel SSL.

aaPanel Panel SSL Set

On the Key textbox, paste the private.key and certificate.crt to Certificate (in pem format). Click Save.

aaPanel Custom Certificate

Then refresh your aaPanel.

aaPanel Panel with SSL from ZeroSSL

Step 6: Install and Configure aaPanel Mail Server

Before anything else, we need to install Redis.

Go to Settings > Search Redis > Install.

Install Redis aaPanel

After installing Redis, we will assign a password. Go to Setting > Performance tuning > requirepass and assign a secure passoword.

Redis Add Password

Now we will search Mail Server that we’ve installed on the App Store awhile ago.

Configure Mail Server aaPanel

You will be asked, “Mail Server is not installed, is it installed?”. Just click Confirm.

You should be able to see Ready on all environments. Then click Submit.

Mail Server Environment aaPanel

Once the initialization is completed, we’ll add a domain.

But first, we will add initial A records on Cloudflare.

You should have the A records like in the example below.

Add A Records for Mail Server aaPanel

Now go back to your aaPanel and add a domain. Just click Add Domain.

aaPanel Add Domain Mail Server

aaPanel Add Domain and A Record

We need to add SSL for the domain. I’ll be using Cloudflare. We’ll getting our API key.

Cloudflare API Token Overview

Cloudflare Global API Key

Go back to aaPanel and click Add SSL.

Add SSL Domain aaPanel Part 1

Choose Cloudflare from Select DNS API drop down.

Paste your Global API Key along with your Cloudflare email. Click Save.

Add API Key aaPanel

Select the domain you want to add SSL and click Apply.

Add SSL Domain aaPanel Part 2

Add SSL Domain aaPanel Part 3
Successfully installed SSL certificate.

Step 7: Add MX, DKIM, DMARC and SPF Records

Now we will add MX, DKIM, DMARC and SPF records to Cloudflare.

Just click your domain and it will pop up a set of records.

aaPanel Mail Server Records

Copy and paste these values to Cloudflare.

For SPF, I will add my IPv4 and IPv6.

The default value is v=spf1 a mx -all. It will become v=spf1 a mx ip4: ip6:2a01:7a7:2:3343::3da9:4dc1 -all.

This should be your final DNS records look like.

DNS Records aaPanel

We will add a user to send emails.

Add User Email Box

Fill in the necessary details for your email. Be sure that you use a strong password.

Add User for aaPanel Mail server

User Added Mail Server aaPanel

Step 8: Test Email Deliverability

Finally, the best part is the excitement of having a functional email server.

Now let’s test its deliverability using Mail-Tester.

Send Test Email to Mail Tester aaPanel Mail Server

We got a 10/10!

Perfect Mail-Tester Score for aaPanel Mail Server

What about for Gmail and Proton Mail?

aaPanel Mail Server Test Email to Gmail Proton Mail

We received it in our inbox directly!

aaPanel to Gmail

Also to Proton Mail!

aaPanel to Proton Mail

Then let’s reply with a thank you.

Reply from Proton Mail to aaPanel

Received a Reply from Proton Mail to aaPanel

Received a Reply from Gmail to aaPanel

We receive it! We can now send and receive email messages with our aaPanel!

Step 9: Add More Domains and Email

Open the Mail Server application.

Go to Domain List > Add Domain.

Add New Domain aaPanel Mail Server

Ensure you have an A record on your DNS provider.

Then enter your domain name and its A record value.

Add Domain and A DNS Record aaPanel

Then we need to add SSL for our newly added domain.

As usual, we’ll use Cloudflare for the SSL.

Add SSL for New Domain aaPanel

Once the SSL is issued, we will add our DNS records. Click the newly added domain to show the DNS records to be added.

New Record Value for New Domain aaPanel

Ensure the new domain’s DNS records (MX record, SPF, DKIM, and DMARC) are correctly configured to point to your server’s IP address.

This is what your DNS records look like.

In case you cannot receive emails, use softfails authentication ~all instead of -all in SPF.

DNS management for New Domain Added in aaPanel Mail ServerNext, we will add a user so that we can send an email.

Add New User for New Domain aaPanel

Now let’s test our email.

Email Test of New Domain to Gmail aaPanel Mail Server

It went directly to our Gmail inbox.

Let’s reply with a thank you.

Reply Received from Gmail to aaPanel Mail Server

If you want to add more domains, just rinse and repeat this process.

Now we have a fully functional multi-domain email server using aaPanel!


Emails Not Sending/Receiving.

Verify DNS settings and ensure MX records are correctly configured.

Software package installation lags.

Close the installation box and restart the panel.

Panel SSL doesn’t issue SSL.

Use ZeroSSL instead of aaPanel Let’s Encrypt SSL


Can I host unlimited domains and email accounts?

Yes, you can host multiple domains and email accounts as long as your server resources (CPU, RAM, storage) can handle the load.

How can I ensure email deliverability?

Implement SPF, DKIM, and DMARC records for each domain. Regularly monitor email server logs and ensure your server’s IP address is not blacklisted.

How can I use aaPanel SMTP relay?

Open the Mail Server app and go to Domain List. From there on, click the user and it will show you the SMTP and IMAP settings. You can use it on your email clients as well as on smartphones.

Final Thoughts

Managing multiple domains and email accounts on aaPanel is a powerful way to consolidate your web and email hosting on a single server.

So, I’ve managed to show you how to host an email server with multiple domains using aaPanel, RackNerd, and Cloudflare.

If you are facing roadblocks, comment them down, I’m here to help.

Leave a Reply

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