How to install and configure Mail Server on Centos 7/RHEL 7


Mail Server

The mail server is called as an e-mail server. This can be used to send and receive the emails over the network. There are two types of mail servers such as Incoming and Outgoing mail servers. The outgoing mail servers can be used Simple Mail Transfer Protocol. The incoming mail servers use pop3 or IMAP. POP3 servers can store the sent and received emails on local storage. But, IMAP servers store the copy of emails on servers. In some scenarios, POP3 can also store emails on Servers.

In this article, we will be known about the installation of postfix and dovecot on CentOs and RHEL.


We can install postfix service by using the following command

#yum -y install postfix

Once the installation completes, enable and start postfix service as follows

#systemctl enable postfix
#systemctl start postfix

When the postfix service starts, it starts its main service called as master. The master service again starts three another services such as nqmgr, pickup and smptd. The nqmgr service is used for transmission, delivery and relay of mail. Pickup service can be used for transfer of messages and smptd for incoming mail.

Now change the configuration of postfix by editing the file /etc/postfix/

#vi /etc/postfix/

Change the following options and uncomment                                          #line 75                                                 #line 83
myorigin=$mydomain                                                       #line 99
inet_interfaces=all                                                      #line 113
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain   #line 165
mynetworks=,                                       #line 264
relay_domains= leave blank                                               #line 296
relayhost=                                                   #line 318
home_mailbox = Maildir/                                                  #line 419

Check configuration errors by using command

#postfix check

Now restart the postfix service

#systemctl restart postfix

We can also change the configuration by using postconf command

[root@mail ~]# postconf myorigin
myorigin = $mydomain

Shows the original value. We can change it as follows

postconf -e ‘myorigin = $mydomain’

Similarly, we can change all the values mentioned above.
Add the firewall rule to allow the SMTP service as follows

# firewall-cmd --add-service=smtp --permanent
#firewall-cmd reload


Dovecot service

Which service can be helpful to fetching mails from the mailbox and reading those emails. The service uses mainly two protocols such as
POP3(port no 110)
POP3s(port no 995)
IMAP (port no 143)
IMAPs (port no 993)

We can install dovecot package by using the following command

#yum - y install dovecot

Now enable and start dovecot service as follows

#systemctl enable dovecot
#systemctl start dovecot

Now edit the dovecot.conf file

#vi /etc/dovecot/dovecot.conf

Now Uncomment the line 24 and save it by pressing :+wq

protocols = imap pop3 lmtp

Edit the file 10-auth.conf

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

Uncomment line 10 and change the value  to no

disable_plaintext_auth = no

In Line 97 change the value to plainlogin

auth_mechanisms = plain login

Now edit 10-mail.conf file

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

Uncomment the line 24

 mail_location = maildir:~/Maildir

check the line 289 is uncommented or not

mbox_write_locks = fcntl

Now restart dovecot service

#systemctl restart dovecot

Now check the services by using telnet command as follows

#telnet 25
#telnet 143

If telnet is not installed on your system install it by using the following command

#yum -y install telnet

Now send the sample by using mailx command and check it as follows

[root@mail ~]# mailx
Subject: hello
Mail server installation complets
[root@mail ~]# su admin
[admin@mail root]$ cat /var/spool/mail/admin
From  Wed Mar 15 04:26:01 2017
Return-Path: <>
Received: by (Postfix, from userid 0)
        id 4EC994612597; Wed, 15 Mar 2017 04:26:01 -0400 (EDT)
Date: Wed, 15 Mar 2017 04:26:00 -0400
Subject: hello
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <>
From: (root)

Mail server installation complets

[admin@mail root]$

Now install the email client applications like Thunderbird, Outlook mail etc.

[root@mail ~]# yum -y install thunderbird
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
 * base:
 * epel:
 * extras:
 * updates:
 * webtatic:
Resolving Dependencies
--> Running transaction check
---> Package thunderbird.x86_64 0:45.7.0-1.el7.centos will be installed
--> Processing Dependency: nss >= 3.21.0 for package: thunderbird-45.7.0-1.el7.centos.x86_64
--> Processing Dependency: nspr >= 4.11.0 for package: thunderbird-45.7.0-1.el7.centos.x86_64
--> Running transaction check
---> Package nspr.x86_64 0:4.10.8-2.el7_1 will be updated
---> Package nspr.x86_64 0:4.13.1-1.0.el7_3 will be an update
---> Package nss.x86_64 0:3.19.1-18.el7 will be updated
--> Processing Dependency: nss = 3.19.1-18.el7 for package: nss-sysinit-3.19.1-18.el7.x86_64
--> Processing Dependency: nss(x86-64) = 3.19.1-18.el7 for package: nss-tools-3.19.1-18.el7.x86_64
---> Package nss.x86_64 0:3.28.2-1.6.el7_3 will be an update
--> Processing Dependency: nss-util >= 3.28.2-1.1 for package: nss-3.28.2-1.6.el7_3.x86_64
--> Processing Dependency: nss-softokn(x86-64) >= for package: nss-3.28.2-1.6.el7_3.x86_64
--> Processing Dependency: for package: nss-3.28.2-1.6.el7_3.x86_64
--> Processing Dependency: for package: nss-3.28.2-1.6.el7_3.x86_64
--> Running transaction check
---> Package nss-softokn.x86_64 0: will be updated
---> Package nss-softokn.x86_64 0: will be an update
--> Processing Dependency: nss-softokn-freebl(x86-64) >= for package: nss-softokn-
---> Package nss-sysinit.x86_64 0:3.19.1-18.el7 will be updated
---> Package nss-sysinit.x86_64 0:3.28.2-1.6.el7_3 will be an update
---> Package nss-tools.x86_64 0:3.19.1-18.el7 will be updated
---> Package nss-tools.x86_64 0:3.28.2-1.6.el7_3 will be an update
---> Package nss-util.x86_64 0:3.19.1-4.el7_1 will be updated
---> Package nss-util.x86_64 0:3.28.2-1.1.el7_3 will be an update
--> Running transaction check
---> Package nss-softokn-freebl.x86_64 0: will be updated
---> Package nss-softokn-freebl.x86_64 0: will be an update
--> Finished Dependency Resolution

Dependencies Resolved

 Package                            Arch                   Version                              Repository               Size
 thunderbird                        x86_64                 45.7.0-1.el7.centos                  updates                  64 M
Updating for dependencies:
 nspr                               x86_64                 4.13.1-1.0.el7_3                     updates                 126 k
 nss                                x86_64                 3.28.2-1.6.el7_3                     updates                 873 k
 nss-softokn                        x86_64                           base                    306 k
 nss-softokn-freebl                 x86_64                           base                    204 k
 nss-sysinit                        x86_64                 3.28.2-1.6.el7_3                     updates                  58 k
 nss-tools                          x86_64                 3.28.2-1.6.el7_3                     updates                 496 k
 nss-util                           x86_64                 3.28.2-1.1.el7_3                     updates                  73 k

Transaction Summary
Install  1 Package
Upgrade             ( 7 Dependent packages)

Total size: 66 M
Total download size: 66 M
Downloading packages:
updates/7/x86_64/prestodelta                                                                           | 430 kB  00:00:04
Delta RPMs reduced 1.0 M of updates to 438 k (59% saved)
(1/6): nss-3.21.3-2.el7_3_3.28.2-1.6.el7_3.x86_64.drpm                                                 | 357 kB  00:00:03
(2/6): nss-util-3.21.3-1.1.el7_3_3.28.2-1.1.el7_3.x86_64.drpm                                          |  35 kB  00:00:02
(3/6): nss-tools-3.28.2-1.6.el7_3.x86_64.rpm                                                           | 496 kB  00:00:04
(4/6): nspr-4.10.8-2.el7_1_4.13.1-1.0.el7_3.x86_64.drpm                                                |  46 kB  00:00:05
(5/6): nss-sysinit-3.28.2-1.6.el7_3.x86_64.rpm                                                         |  58 kB  00:00:04
(6/6): thunderbird-45.7.0-1.el7.centos.x86_64.rpm                                                      |  64 MB  00:05:46
Finishing delta rebuilds of 1 package(s) (126 k)
Total                                                                                         188 kB/s |  65 MB  00:05:54
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : nspr-4.13.1-1.0.el7_3.x86_64                                                                              1/15
  Updating   : nss-util-3.28.2-1.1.el7_3.x86_64                                                                          2/15
  Updating   : nss-softokn-freebl-                                                               3/15
  Updating   : nss-softokn-                                                                      4/15
  Updating   : nss-3.28.2-1.6.el7_3.x86_64                                                                               5/15
  Updating   : nss-sysinit-3.28.2-1.6.el7_3.x86_64                                                                       6/15
  Updating   : nss-tools-3.28.2-1.6.el7_3.x86_64                                                                         7/15
  Installing : thunderbird-45.7.0-1.el7.centos.x86_64                                                                    8/15
  Cleanup    : nss-tools-3.19.1-18.el7.x86_64                                                                            9/15
  Cleanup    : nss-sysinit-3.19.1-18.el7.x86_64                                                                         10/15
  Cleanup    : nss-3.19.1-18.el7.x86_64                                                                                 11/15
  Cleanup    : nss-softokn-                                                                     12/15
  Cleanup    : nss-util-3.19.1-4.el7_1.x86_64                                                                           13/15
  Cleanup    : nspr-4.10.8-2.el7_1.x86_64                                                                               14/15
  Cleanup    : nss-softokn-freebl-                                                              15/15
  Verifying  : nspr-4.13.1-1.0.el7_3.x86_64                                                                              1/15
  Verifying  : nss-tools-3.28.2-1.6.el7_3.x86_64                                                                         2/15
  Verifying  : thunderbird-45.7.0-1.el7.centos.x86_64                                                                    3/15
  Verifying  : nss-softokn-                                                                      4/15
  Verifying  : nss-softokn-freebl-                                                               5/15
  Verifying  : nss-3.28.2-1.6.el7_3.x86_64                                                                               6/15
  Verifying  : nss-sysinit-3.28.2-1.6.el7_3.x86_64                                                                       7/15
  Verifying  : nss-util-3.28.2-1.1.el7_3.x86_64                                                                          8/15
  Verifying  : nss-tools-3.19.1-18.el7.x86_64                                                                            9/15
  Verifying  : nss-softokn-freebl-                                                              10/15
  Verifying  : nss-softokn-                                                                     11/15
  Verifying  : nss-3.19.1-18.el7.x86_64                                                                                 12/15
  Verifying  : nss-sysinit-3.19.1-18.el7.x86_64                                                                         13/15
  Verifying  : nspr-4.10.8-2.el7_1.x86_64                                                                               14/15
  Verifying  : nss-util-3.19.1-4.el7_1.x86_64                                                                           15/15

  thunderbird.x86_64 0:45.7.0-1.el7.centos

Dependency Updated:
  nspr.x86_64 0:4.13.1-1.0.el7_3                nss.x86_64 0:3.28.2-1.6.el7_3         nss-softokn.x86_64 0:
  nss-softokn-freebl.x86_64 0: nss-sysinit.x86_64 0:3.28.2-1.6.el7_3 nss-tools.x86_64 0:3.28.2-1.6.el7_3
  nss-util.x86_64 0:3.28.2-1.1.el7_3

[root@mail ~]#

Now open the Thunderbird email application and configure as mail server, click on continue and select advanced settings.


configure the server host name as per the system name of mail server and click on Re-test and Done to complete.

Now we can send and receive mail graphically by using Thunderbird. In next article, we will learn about the Roundcube mail installation and configuration. If you want to join this discussion, feel free to leave a comment!