How to Install and Setup a Mailserver on a CentOS 7 VPS with Exim

05 Oct 2018 0 9  0
How to Install and Setup a Mailserver on a CentOS 7 VPS with Exim
How to Install and Setup a Mailserver on a CentOS 7 VPS with Exim

In the following tutorial, we will teach you how to install and set up a mailserver using Exim and Dovecot on a CentOS 7 VPS.

We will use a CentOS based VPS host plan for this tutorial; it will be pre-installed with minimal CentOS 7 OS.

What is Exim?

Exim is a mail transfer agent (MTA) which is commonly used on Unix-like operating systems. Exim is a free software, which is distributed under the terms of the GNU (General Public License), and it’s trying to be a general and flexible mailer with extensive facilities for verifying any incoming e-mail.

What is Dovecot?

Dovecot is an open-source IMAP and POP3 email server for Linux/UNIX-like systems. It was written with security as its top priority. Dovecot is an amazing choice for both small and large installations.


Begin by sshing to your server then start a screen session with the following command:

## screen -U -S exim-dovecot

After you are in the screen session, update your CentOS 7 VPS with yum as follows:

## yum update


With the following command, we can enable the EPEL repository on the CentOS system:

## yum install

If you receive a 404 not found error, use the following link,, then install the latest epel-release rpm package available.

Confirm that EPEL has been enabled on your system using the following command:

## yum repolist

If EPEL is enabled, install some useful tools with this:

## yum install file perl-Mail-SPF.noarch openssl vim


Because we will be using SSL in Dovecot and Exim, we will need to have an SSL certificate. You may create your own self-signed SSL certificate for with the commands below:

## mkdir /root/SSL/ -p

## cd /root/SSL/

## openssl req -nodes -x509 -newkey rsa:2048 -keyout -out -days 365


With the command below, we will move the SSL certificate and key to /etc/ssl directory:

## cp /etc/ssl/


Use the command below to install exim on the CentOS 7 VPS with yum:

## yum install exim

Now, we will open the file /etc/exim/exim.conf using your favorite editor, then configure exim as follows:

## cp /etc/exim/exim.conf{,.orig}

## vim /etc/exim/exim.conf

primary_hostname =

domainlist local_domains = @ :

tls_advertise_hosts = *

tls_certificate = /etc/ssl/

tls_privatekey = /etc/ssl/

auth_advertise_hosts = *

Look for the transport section and modify the following:


driver = appendfile

directory = $home/Maildir






Scroll down to the authenticators section and append the next lines:


driver = dovecot

public_name = LOGIN

server_socket = /var/run/dovecot/auth-client

server_set_id = $auth1


driver = dovecot

public_name = PLAIN

server_socket = /var/run/dovecot/auth-client

server_set_id = $auth1

Initiate the EXIM MTA then append it to the system’s startup using systemctl

## systemctl start exim

## systemctl status exim

## systemctl enable exim



Next, we will install Dovecot on the system using yum:

## yum install dovecot

After it’s installed, configure SSL in Dovecot by modifying the following:

## vim /etc/dovecot/conf.d/10-ssl.conf

ssl = yes

ssl_cert = </etc/ssl/

ssl_key = </etc/ssl/

Next we will allow plaintext authentication in /etc/dovecot/conf.d/10-auth.conf:

## vim /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no

auth_mechanisms = plain login

Configure the mailbox location and enter this in /etc/dovecot/conf.d/10-mail.conf:

## vim /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir

Now we’ll set up Dovecot so it grants Exim the ability to use its authentication system in


## vim /etc/dovecot/conf.d/10-master.conf

service auth {


unix_listener auth-client {

mode = 0660

user = exim



Start up Dovecot and append it to the system’s start-up using the following:

## systemctl start dovecot

## systemctl status dovecot

## systemctl enable dovecot


Create a System User:

## useradd -m test

## passwd test


Add a comment

Leave a Reply