Blog Post Header
Tutorials November 11, 2025 16 views

How to Set Up a Mail Server in CentOS

How to Set Up a Mail Server in CentOS

How to Set Up a Mail Server in CentOS

Setting up a mail server in CentOS can be a daunting task, but with the right guidance, it can be achieved smoothly. In this tutorial, we will walk you through the steps to set up a mail server in CentOS, using Postfix, Dovecot, and Roundcube.

Step 1: Install Postfix

Postfix is a popular open-source mail transfer agent (MTA) that will handle the sending and receiving of emails on your server. To install Postfix, run the following command:

yum install postfix

Once Postfix is installed, you will need to configure it by editing the main configuration file located at /etc/postfix/main.cf. Make sure to set the myhostname and mydomain variables to your server's hostname and domain name respectively.

Step 2: Install Dovecot

Dovecot is an open-source IMAP and POP3 server that will allow users to access their emails on the server. To install Dovecot, run the following command:

yum install dovecot

After installing Dovecot, edit the configuration file located at /etc/dovecot/dovecot.conf to configure authentication mechanisms, SSL certificates, and other settings.

Step 3: Install Roundcube

Roundcube is a web-based email client that will allow users to access their emails through a web browser. To install Roundcube, run the following commands:

yum install epel-release
yum install roundcubemail

After installing Roundcube, configure it by editing the configuration file located at /etc/roundcubemail/config.inc.php. Set the database type, host, username, password, and other settings to connect Roundcube to your mail server.

Step 4: Configure Firewall Rules

Before you can start sending and receiving emails, you will need to open the necessary ports in your server's firewall. Run the following commands to open ports 25, 587, 993, and 995:

firewall-cmd --zone=public --add-port=25/tcp --permanent
firewall-cmd --zone=public --add-port=587/tcp --permanent
firewall-cmd --zone=public --add-port=993/tcp --permanent
firewall-cmd --zone=public --add-port=995/tcp --permanent
firewall-cmd --reload

Step 5: Start the Services

After configuring Postfix, Dovecot, and Roundcube, start the services and enable them to automatically start on boot:

systemctl start postfix
systemctl enable postfix
systemctl start dovecot
systemctl enable dovecot
systemctl start httpd
systemctl enable httpd

Conclusion

Congratulations! You have successfully set up a mail server in CentOS using Postfix, Dovecot, and Roundcube. You can now start sending and receiving emails on your server. Remember to regularly update and secure your mail server to protect it from potential threats.

Author: Admin
Join Our Community

Create an account to leave comments, save your favorite posts, and get personalized recommendations.