Install and Configure Dovecot on CentOS

This section provides a tutorial example on how to install, configure and run Dovecot server on CentOS systems.

Installing Dovecot on CentOS 8 is relatively easy, since it has a ready-to-run binary package in CentOS repository. Here is what I did to install, configure and run Dovecot on my CentOS 8 computer.

1. Install Dovecot with "dnf" command.

herong$ sudo dnf install dovecot
...
Installed:
    dovecot-1:2.3.8-2.el8_2.2.x86_64
    clucene-core-2.3.3.4-31.20130812.e8e3d20git.el8.x86_64

2. Configure Dovecot. The "mail_location = maildir:~/Maildir" needs to match how Postfix manages mail boxes on the server.

herong$ cd /etc/dovecot/
herong$ sudo cp dovecot.conf dovecot-bck.conf

herong$ sudo vi /etc/dovecot/dovecot.conf
  protocols = imap pop3 lmtp submission

herong$ sudo vi /etc/dovecot/conf.d/10-mail.conf
  mail_location = maildir:~/Maildir

herong$ sudo vi /etc/dovecot/conf.d/10-auth.conf
  disable_plaintext_auth = yes
  auth_mechanisms = plain login

herong$ sudo vi /etc/dovecot/conf.d/10-master.conf
  ...
  service auth {
    unix_listener auth-userdb {
      #mode = 0666
      user = postfix
      group = postfix
    }
    ...
  }

3. Make sure that Postfix is running.

herong$ ps -ef | grep postfix

postfix  14318 31224  0 20:44 ?  00:00:00 pickup -l -t unix -u
root     31224     1  0 Nov13 ?  00:00:01 /usr/libexec/postfix/master -w
postfix  31226 31224  0 Nov13 ?  00:00:00 qmgr -l -t unix -u
postfix  31302 31224  0 Nov13 ?  00:00:00 tlsmgr -l -t unix -u

4. Enable Dovecot and start it. Too bad, it failed to bind on port 587.

herong$ sudo systemctl enable dovecot
Created symlink /etc/systemd/system/multi-user.target.wants/dovecot.service
  -> /usr/lib/systemd/system/dovecot.service.

herong$ sudo systemctl start dovecot

herong$ sudo systemctl status dovecot
06:39:23 localhost.localdomain dovecot[30210]:
  Error: bind(::, 587) failed: Permission denied

5. Check to see who is listening on port 587. I see Postfix master program in the output. So both Postfix and Dovecot can listen to port 587? I will check it out later.

herong$ sudo netstat -lpt

Proto Local Address  Foreign Address  State       PID/Program name
tcp   0.0.0.0:25     0.0.0.0:*        LISTEN      31224/master
tcp   0.0.0.0:587    0.0.0.0:*        LISTEN      31224/master
...

herong$ ps -ef | grep master
root     31224     1  0 Nov13 ?       /usr/libexec/postfix/master -w

6. Turn off port 587 on Dovecot by setting the port number to 0 with "port=0" on the "submission" service.

herong$ sudo vi /etc/dovecot/conf.d/10-master.conf

...
service submission-login {
  inet_listener submission {
    #port = 587
    #port = 0 # bad syntax. do not leave any space before and after the =
    port=0
  }
}

7. Start Dovecot again.

herong$ sudo systemctl start dovecot

herong$ sudo systemctl status dovecot
* dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled; vendor preset: disabled)
   Active: active (running) since 2023-11-15 08:00:09 EST; 14s ago
     Docs: man:dovecot(1)
           http://wiki2.dovecot.org/
  Process: 31486 ExecStop=/usr/bin/doveadm stop (code=exited, status=0/SUCCESS)
  Process: 31495 ExecStartPre=/usr/libexec/dovecot/prestartscript (code=exited, status=0/)
 Main PID: 31503 (dovecot)
    Tasks: 4 (limit: 26213)
   Memory: 5.6M
   CGroup: /system.slice/dovecot.service
           |-31503 /usr/sbin/dovecot -F
           |-31504 dovecot/anvil
           |-31505 dovecot/log
           |-31506 dovecot/config

systemd[1]: Starting Dovecot IMAP/POP3 email server...
systemd[1]: Started Dovecot IMAP/POP3 email server.
dovecot[31503]: master: Dovecot v2.3.8 (9df20d2db) starting up for imap, pop3, lmtp, submission

Cool! I think my Dovecot server is running and ready to handle IMAP and POP3 requests.

Table of Contents

 About This Book

 Introduction to Email

 Postfix - Mail Transport Agent (MTA)

 SSL/TLS Secure Connections with Postfix Server

Dovecot - IMAP and POP3 Server

 What Is Dovecot

Install and Configure Dovecot on CentOS

 Test Dovecot IMAP Server with "telnet" Client

 Test Dovecot POP3 Server with "telnet" Client

 Keep Deleted Emails on Dovecot

 Turn on Dovecot Server Logging for Troubleshooting

 "doveadm" Command - Dovecot's Administration Utility

 SSL/TLS Secure Connections with Dovecot Server

 Email Client Tools - Mail User Agents (MUA)

 Mozilla Thunderbird - Mail User Agents (MUA)

 References

 Full Version in PDF/EPUB