Deploying a mail server on Red Hat can seem daunting, but with the right steps, it can be a straightforward process. This guide will walk you through the installation and configuration of Postfix as the Mail Transfer Agent (MTA), Dovecot as the IMAP/POP3 server, and Roundcube as the webmail interface.
Prerequisites
- A server running Red Hat Enterprise Linux (RHEL)
- Root or sudo access to the server
- Basic knowledge of Linux command line
Step 1: Update Your System
Ensure your server is up-to-date:
sudo yum update -y
Step 2: Install Postfix
Postfix is a popular MTA used to route and deliver email.
sudo yum install postfix -y
Start and enable Postfix:
sudo systemctl start postfix
sudo systemctl enable postfix
Step 3: Install Dovecot
Dovecot is a secure IMAP and POP3 server.
sudo yum install dovecot -y
Start and enable Dovecot:
sudo systemctl start dovecot
sudo systemctl enable dovecot
Configure Dovecot by editing /etc/dovecot/dovecot.conf
and /etc/dovecot/conf.d/10-mail.conf
:
sudo nano /etc/dovecot/dovecot.conf
Ensure the following lines are present:
protocols = imap pop3
mail_location = maildir:~/Maildir
Step 4: Configure Postfix and Dovecot
Edit the Postfix main configuration file:
sudo nano /etc/postfix/main.cf
Add or modify the following lines:
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/
mynetworks = 127.0.0.0/8 [::1]/128
relay_domains =
mailbox_command = /usr/libexec/dovecot/deliver
Restart Postfix to apply changes:
sudo systemctl restart postfix
Step 5: Install Roundcube Webmail
Install the necessary dependencies:
sudo yum install epel-release -y
sudo yum install httpd php php-mysqlnd php-pear php-intl php-mbstring php-xml php-gd php-zip -y
Download and extract Roundcube:
cd /var/www/html
sudo wget https://github.com/roundcube/roundcubemail/releases/download/1.6.1/roundcubemail-1.6.1-complete.tar.gz
sudo tar -xvf roundcubemail-1.6.1-complete.tar.gz
sudo mv roundcubemail-1.6.1 roundcube
sudo chown -R apache:apache roundcube
Configure Apache for Roundcube:
sudo nano /etc/httpd/conf.d/roundcube.conf
Add the following content:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/roundcube
ServerName mail.example.com
<Directory /var/www/html/roundcube/>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/roundcube_error.log
CustomLog /var/log/httpd/roundcube_access.log combined
</VirtualHost>
Restart Apache:
sudo systemctl restart httpd
sudo systemctl enable httpd
Step 6: Configure Roundcube
Navigate to http://mail.example.com/installer
in your web browser and follow the on-screen instructions to complete the Roundcube installation.
Note: Ensure you delete the installer directory after completing the installation for security reasons:
sudo rm -rf /var/www/html/roundcube/installer
Conclusion
Congratulations! You have successfully deployed a mail server with webmail on Red Hat. Your server is now configured to send and receive emails, and users can access their mail through the Roundcube webmail interface.