Mail server on CentOS 7. Installing Dovecot + Exim + Roundcube

N
Netooze
February 10, 2020

In this article, we will install and configure a mail server using Exim and Dovecot on a CentOS 7.5 VPS using the Roundcube web interface.

We use a CentOS based VPS for this ; pre-installed with minimal CentOS 7.5 

What is Exim?

Exim is a mail transfer agent (MTA) that is commonly used on Unix-like operating systems. Exim is free software distributed under the terms of the GNU (General Public License) and is a versatile and flexible email tool with extensive features for checking incoming emails.

What is Dovecot?

Dovecot is an open-source IMAP and POP3 mail server for Linux/UNIX-like systems. Security has been the cornerstone of this product's focus on flexibility and speed.

Dovecot is a great choice for both small and large email systems.

What is Roundcube?

Roundcube is a web-based email interface that provides the ability to  work with your mailboxes using  IMAP  and  SMTP. The application has powerful functionality and is comparable in capabilities to desktop email clients such as  Outlook Express  or  Mozilla Thunderbird

Preparation and setup

Let's connect an additional EPEL repository, as follows:

# yum install <a class="external free" href="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm">https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm</a>
# yum update
To check that the newly added EPEL repository has connected to our system, enter:
# yum repolist
Then install the following tools:
# yum install file perl-Mail-SPF.noarch openssl nano

Exim installation and configuration

# yum install exim

We will now open the /etc/exim/exim.conf file using your favorite editor, backing it up first, and reshaping it as follows:

# cp /etc/exim/exim.conf{,.original}
# nano /etc/exim/exim.conf

primary_hostname = mail.mypostdomain.com
domainlist local_domains = @ : mypostdomain.com
tls_advertise_hosts = *
tls_certificate = /etc/ssl/mail.mypostdomain.com.crt
tls_privatekey = /etc/ssl/mail.mypostdomain.com.key
auth_advertise_hosts = *

Let's pay attention to the lines tls_certificate and tls_privatekey , we will use the Certificate , you can order it on our website and find the necessary files in the Personal Account - SSL      

Next, let's move on to the transport section and bring it to the form:

local_delivery:
driver = appendfile
directory = $home/Maildir
maildir_format
maildir_use_size_file
delivery_date_add
envelope_to_add
return_path_add

Next, in the authentication section, add the following lines:

dovecot_login:
driver = dovecot
public_name = LOGIN
server_socket = /var/run/dovecot/auth-client
server_set_id = $auth1
dovecot_plain:
driver = dovecot
public_name = PLAIN
server_socket = /var/run/dovecot/auth-client
server_set_id = $auth1

Start exim , and add it to system startup using systemctl: 

# systemctl start exim
# systemctl status exim
# systemctl enable exim

Dovecot setup

# yum install dovecot
After installation, edit the configuration files:

# nano /etc/dovecot/conf.d/10-ssl.conf
ssl = yes
ssl_cert = /etc/ssl/mail.mypostdomain.com.crt
ssl_key = /etc/ssl/mail.mypostdomain.com.key

# nano /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain login

# nano /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir

# vim /etc/dovecot/conf.d/10-master.conf
service auth {
...
unix_listener auth-client {
mode = 0660
user = exim
}
}

Run dovecot , and add it to system startup using systemctl. 

# systemctl start dovecot
# systemctl status dovecot
# systemctl enable dovecot

Roudcube

LAMP
# yum  install roundcubemail

# nano /etc/httpd/conf.d/roundcube.conf

#
# Round Cube Webmail is a browser-based multilingual IMAP client
#

Alias /roundcube /usr/share/roundcubemail
Alias /webmail /usr/share/roundcubemail


Options none
AllowOverride Limit
Require all granted


Options none
AllowOverride Limit
Require all granted

# Those directories should not be viewed by Web clients.

Order Allow,Deny
Deny from all


Order Allow,Deny
Deny from all

# service httpd restart

# mysql -u root -p
mysql> CREATE DATABASE dbroundcube;
mysql> CREATE USER userroundcube@localhost IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES on dbroundcube.* to userroundcube@localhost ;
mysql> FLUSH PRIVILEGES;
mysql> quit

http://mail.mypostdomain.com/roundcube/installer

POP3: 110
IMAP: 143
SMTP: 25

Start your cloud journey? Take the first step right now.