SMTP Mail Server Install Guide - Hashtechwave

Ultimate Guide: Setup Mail Server on CloudPanel Ubuntu 2024

Syed Safwan Abbas
By Syed Safwan Abbas - Full Stack Web Developer 9 Min Read

In today’s digital market, having a reliable and secure mail server is very important for any small business, large enterprise or even just for individuals who want private email solutions. Similarly, if you are tired of unreliable old-school email services that have limited storage and bunch of irrelevant ads, then a self-hosted email server is final solution. Your own SMTP Mail Server will offer more control, privacy and customization that third-party services can’t match.

- Advertisement -

We will walkthrough by setting up Mailcow which is powerful and open-source mail server compatible with CloudPanel which itself, is a user-friendly web hosting control panel running on Ubuntu 20.04 (or later). Even with no prior experience, you will be sending and receiving emails from your own domain in no time. By the end of this article, anyone who followed upon this guide will have a fully functional mail server.

What Do We Need Before Installing Custom Mail Server?

very good dish requires some decent ingredients, and setting up your own email server is no different! To get started, you’ll need these key elements:

- Advertisement -

1. CloudPanel:

This is the foundation of your email server, acting as your kitchen. CloudPanel is a user-friendly web hosting control panel that simplifies server management for Ubuntu. If you don’t already have CloudPanel installed, head over to their official documentation for step-by-step instructions: CloudPanel Installation Guide

2. VPS Server with Ubuntu

To run a mail server efficiently, your VPS should meet the following minimum requirements

- Advertisement -
  • RAM: 2GB (4GB recommended for better performance)
  • CPU: 2 cores (4 cores for optimal performance)
  • Storage: 20GB (SSD recommended for faster I/O)
  • Operating System: Ubuntu 22.04 (or Latest Ubuntu 24.04)

These specifications ensure that your server can handle the mail server’s load without performance issues. But another hurdle is the knowledge of service provider that you are using, here is basic summary:

DigitalOceanKnown for its simplicity and scalability.
AWSOffers a wide range of services and high availability.
LinodeCost-effective with good performance
VultrOffers a balance between cost and performance.
HostingerCheaper but Performance is good (Hostinger is used in this guide)
VPS Service Providers Summary

If You are new to VPS Hosting then Here’s the Complete Guide that will clear all your doubts: What is a VPS and How It Helps?

- Advertisement -

Note: CloudPanel Installation For VPS Hosting from Hostinger

You can navigate to your VPS Manager > Settings > OS & Panel. From there, select OS with Panel and Select CloudPanel with Ubuntu

Buy Hostinger VPS Plan & Get Discount 20% with Best Performance at Cheaper rates

3. DNS Configuration and Reverse DNS

It is highly recommended to make sure Pointer (PTR) record of your VPS Server IP Address matches the Fully Qualified Domain Name (FQDN) for mailcow host. This is set usually at VPS settings provided by vps hosting provider that you leased the IP Address from. For Hostinger here is the method and almost it is same for other hosting providers as well:

- Advertisement -

Process is similar on almost every hostinger provider and as shown in figure where Hostinger VPS is configured to change it’s PTR Record for Reverse DNS.

Ready to Get Cooking? Installing MailCow Mail Server on CloudPanel

Once you’ve gathered essential ingredients, you’re ready to move on to the further steps but before proceeding the installation of MailCow, as we have to configure Reverse DNS Record in Hostinger hPanel then we firstly login to CloudPanel that you installed with help of guide above to add Site and choose reverse proxy on the hostname that we created. for example host.example.com with Reverse Proxy URL as https://127.0.0.1:7443.

- Advertisement -

After setting up Reverse proxy, install SSL Certificate from above menu and generate new Let’s Encrypt Certificate

1. Login SSH as root

Now comes the main part of Mail Server Installation for which we created all pathway from start but first of all we need to connect to VPS terminal using SSH which is provided by every Hostinger provider with credentials.

2. Disable PostFix if installed

Most of time by default with CloudPanel on Ubuntu, PostFix is installed which need to be disable for smooth installation process so for that we will verify installation of postfix mail server and if any, then we will delete it on the spot using following command:

3. Install Docker on Ubuntu

MailCow mail server is the dockerized version containing multiple services required to create an efficient SMTP Mail Server. Here is the command to install Docker with Docker-Compose plugin on your VPS server having Ubuntu Linux installed:

4. Fetch MailCow GitHub Repo

MailCow having a huge community that works regularly for improvements and for that you need to fetch latest release from creators.

Install Git on Ubuntu

If you are new to Ubuntu and never installed Git before then, you need to run sudo apt install git inside your terminal to firsly install Git on your machine.

Hoping you have Git installed then execute following commands one-by-one to pull latest Mail Cow release from Github.

make sure you are in directory /opt/mailcow-dockerized, then run following command in same terminal

mail server hostname
After executing generate config bash file

During configuration you have to set the Mail server hostname (FQDN), e.g., host.domain.com or mail.domain.com that you earlier configured in PTR record.

4. Setup Ports and Bindings

This step is last, now we are one step behind the completion of our mail server. Change the values for HTTP_PORTHTTP_BINDHTTPS_PORTHTTPS_BIND from mailcow.conf file using following command:

Text editor will appear where you have to change above four variables according to following port numbers:

  • HTTP_PORT=7080
  • HTTP_BIND=127.0.0.1
  • HTTPS_PORT=7443
  • HTTPS_BIND=127.0.0.1

after changing press Ctrl+O to save files.

Starting Up Mailcow Mail Server

If you have followed along above steps, then Congratulate yourself. Now you only have to start Mailcow dockerize container with help of following command only:

Conclusion

Installation of the best Mail Server on your VPS with CloudPanel installed on Ubuntu 22.04 or later versions is pretty straightforward. Following this guide step by step, you now have a very reliable and efficient mail server set up, properly configured, and with measures against most security threats. This server will maintain its integrity and performance provided that it is regularly updated and monitored.

We encourage you to go through the whole guide. In case of some issues or if you have questions, please leave a comment. We’re here to help if you need professional assistance—our team will make sure your mail server is set up and running well.

Thank you for following this guide, and happy emailing!

Share This Article
Full Stack Web Developer
Follow:
Syed Safwan Abbas is the owner of HashBitStudio, a digital solutions agency specializing in web development, branding, and digital marketing. He also runs HashTechWave, a popular blog focused on tech and entertainment. As a full-stack developer with expertise in MERN, Next.js, and a wide range of web technologies, Safwan is passionate about creating innovative digital experiences. Before founding HashBitStudio and HashTechWave, he gained extensive experience in both frontend and backend development, refining his skills across various roles. When he's not building cutting-edge websites or writing insightful blog posts, Safwan enjoys exploring the latest tech trends, experimenting with new frameworks, and working on creative projects.