How to Run a Linux Mail Server
In today’s article, we briefly explain what is the SMTP protocol. We also provide a step-by-step tutorial on how to install a mail server on Linux.
List of content you will read in this article:
There are plenty of e-mail services out there, however, how trustworthy are they? For normal day-to-day e-mail use, typical email services are just secure enough. Nevertheless, if you are dealing with sensitive data, it is best to have your own mail server as in this case, you get full control over where your emails go through. In today’s article, we will discuss about the SMTP (i.e. Simple Mail Transfer Protocol) protocol and show you a step-by-step tutorial on how to run your own mail server on Linux.
What is an SMTP Server?
SMTP is a part of the application layer of the TCP/IP protocol. With the use of a process named “store and forward”, it transfers emails across networks. An SMTP server is an application that’s primary purpose is to send, receive, and/or relay outgoing mail between email senders and receivers.
Without an SMTP server, your email wouldn’t make it to its destination. Once you hit “send,” your email transforms into a string of code that is then sent to the SMTP server. The SMTP server is able to process that code and pass on the message. If the SMTP server wasn’t there to process the message, it would be lost in translation.
How to Run a Mail Server on Linux
Please note that this tutorial is made for Ubuntu/Debian.
In this tutorial, we will use the Postfix mail server and the Roundcube webmail application.
- First, set a valid FQDN (i.e. Fully Qualified Domain Name) for your server with the following command. Do not forget to replace “monovm.com” with your domain name.
sudo hostnamectl set-hostname mail.monovm.com
- Now, add a MX and A records for your domain in your DNS control panel.
- Once that is done, you will need to install Apache2, MariaDB and PHP :
sudo apt install apache2 apache2-utils mariadb-server mariadb-client php7.4 libapache2-mod-php7.4 php7.4-mysql php-net-ldap2 php-net-ldap3 php-imagick php7.4-common php7.4-gd php7.4-imap php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-gmp php-net-smtp php-mail-mime php-net-idna2 mailutils
sudo apt-get install postfix
- Once that is installed, you need to install an MDA (i.e. Mail Delivery Agent), we chose Dovecot
sudo apt-get install dovecot-imapd dovecot-pop3d
sudo systemctl restart dovecot
tar -xvf roundcubemail-1.4.8.tar.gz
sudo mv roundcubemail-1.4.8 /var/www/html/roundcubemail
sudo chown -R www-data:www-data /var/www/html/roundcubemail/
sudo chmod 755 -R /var/www/html/roundcubemail/
- Once the above steps are completed, you need to create a new database and a user for Roundcube as well as grant all the permissions. Note: do not include “MariaDB [(none)]>” in the commands you are writing.
MariaDB [(none)]> CREATE DATABASE roundcube DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
MariaDB [(none)]> CREATE USER roundcubeuser@localhost IDENTIFIED BY ‘password’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON roundcube.* TO roundcubeuser@localhost;
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit;
sudo nano /etc/apache2/sites-available/roundcube.conf
Then, add the following configuration to it:
CustomLog $/roundcube_access.log combined
14 Best Linux Mail Servers in 2023 (Free + Open Source)
Ever had a promotion email from a company? Who hasn’t, right? Even if you have been using Gmail or another free mail service until now, you’ve had quite a few run-ins with mail servers. With the clear importance of mail servers, it is difficult to imagine launching a successful business without taking advantage of the best mail servers. To manage your daily backlog of emails, you need the best Linux email server around. This blog post will help you select the best mail servers for Linux. Let us now dive in to learn more about the top 14 of the best Linux mail servers.
What is a Mail Server?
As a user, we all have some experience with email clients like Microsoft Outlook or Thunderbird. But when you go from being a user to trying to start your own business, you will come to see the other side of emails: mail servers.
A Linux mail server software is used for transferring emails from one point of the Internet to another. Also known as Mail Transfer Agents (MTAs), they receive incoming emails from other servers before forwarding them to the user’s client software and vice versa. Although almost all mail servers handle both incoming and outgoing emails, the two functions are separate and follow different protocols. An incoming mail server usually operates using the Post Office Protocol 3 (POP3) or the Internet Message Access Protocol (IMAP), while Simple Mail Transfer Protocol (SMTP) is used to send the emails they have previously received from the user’s client software.
Which Email Protocol Is Capable of Sending Emails? (SMTP, IMAP, and POP)
What Are the Requirements for Hosting a Linux Mail Server?
The advantages of hosting your own mail server are improving the security and privacy of your emails and performing email marketing campaigns more effectively. A Linux distro is the perfect choice for hosting mail servers as Linux is lightweight, highly customizable, and doesn’t take much of your hardware resources. Even with a Linux OS, you still need a whole other computer with enough storage and memory resources to act as your mail server. Now, buying a computer with the right specs can get expensive. That’s why hosting your mail server on a VPS is a great option.
A virtual private server is a hosting service that acts like a virtual computer. You can get a VPS with a Linux distro entirely dedicated to your Linux mail server software. Cloudzy is just the right solution for hosting the best Linux mail servers. Cloudzy’s Linux VPS is available in more than 15 locations across 3 continents, allowing you to host your mail server close to your customer base or anywhere you desire. These virtual private servers are extremely powerful since Cloudzy uses the latest hardware resources for backing the servers. You can choose the resources you need to host your Linux mail server, and as your business grows, you can easily scale your plans up.
Overall, VPS is an affordable solution, but Cloudzy is known for offering the most budget-friendly prices, which is beyond remarkable considering the high-quality services. Bonus fact: If you get your VPS for mail server from Cloudzy, you’ll get your Linux OS free and pre-installed. We offer a complete selection of Linux distros.