Written by , Updated on April 27, 2020

Dovecot is an open-source service for IMAP and POP3 on Unix-like operating systems. It focused on lightweight and secure mail server available for most of the Linux operating system. This tutorial will help you to install and configure POS3/IMAP using Dovecot on CentOS 8 operating system.

Step 1 – Install Dovecot on CentOS 8

Dovecot package is available under the AppStream yum repository. You just need to install package using the yum/dnf package manager on CentOS 8 system.

sudo dnf -y install dovecot

Step 2 – Configure Dovecot

Once the installation finished, configure Dovecot server as per your requirements. Here is the quick and useful configuration of Dovecot to work on your system.

  • Edit Dovecot main configuration file and un-comment below lines to enable POP3 and IMAP protocols. Also configure Dovecot on all interfaces.
    sudo vi /etc/dovecot/dovecot.conf
    
    protocols = imap pop3 lmtp
    listen = *, :: 
    
  • Then edit the authentication file for Dovecot and update following values.

    sudo vi /etc/dovecot/conf.d/10-auth.conf
    
    disable_plaintext_auth = no
    auth_mechanisms = plain login
    
  • After that, edit mail configuration file to configure location of the Mailbox. Make sure to set this to correct location where your email server is configure to save users emails.

    sudo vi /etc/dovecot/conf.d/10-mail.conf
    
    mail_location = maildir:~/Maildir
    
  • Next, edit below configuration file and set the username and group name of the mail server is running with.

    sudo vi /etc/dovecot/conf.d/10-master.conf
    
      unix_listener /var/spool/postfix/private/auth {
        mode = 0666
        user = postfix
        group = postfix
      }
    
  • Finally edit Dovecot SSL configuration file. Set SSL to yes or required. By default it uses self singed certificate, if you have your own certificates update them as followings.

    sudo vi /etc/dovecot/conf.d/10-ssl.conf
    
    ssl = yes
    
    ssl_cert = /letsencrypt/live/mail.tecadmin.net/cert.pem
    ssl_key = /letsencrypt/live/mail.tecadmin.net/privkey.pem
    

Step 3 – Manage Dovecot Service

We can manage dovecot using systemctl command line tool. Use the following command to enable Dovecot service.

sudo systemctl enable dovecot.service

Use the following commands to start/stop or restart Dovecot service:

sudo systemctl start dovecot.service
sudo systemctl stop dovecot.service
sudo systemctl restart dovecot.service

Use the below command to view the current status of the service

sudo systemctl status dovecot.service

Step 4 – Test Configuration

An username “rahul” is created on my CentOS 8 system. We need mutt command line utility to connect mailbox using imaps protocol.

sudo dnf install mutt

Then connect to mailbox using below command:

mutt -f imaps://[email protected]

This will prompt to accept certificate (Press a for accept alwys). After that it will prompt for the password. Enter user password and press enter. You will see the emails of your account.

How to Install Dovecot on CentOS 8 Dovecot Email IMAP Mail Services POP

Step 5 – Adjust Rules in FirewallD

To access your mail server from another computer, you must adjust the firewall rules to allow connections to the server on the necessary ports. The default POP/IMAP ports are:

  • IMAP – 143
  • IMAPS – 993
  • POP3 – 110
  • POP3S – 995

Run the below commands to add firewall rules:

sudo firewall-cmd --add-service={pop3,imap} --permanent
sudo firewall-cmd --add-service={pop3s,imaps} --permanent

Then reload the changes.

sudo firewall-cmd --reload

Conclusion

Dovecot service has been configured on your system. You have configured your server to access user mailbox via POP3 or IMAP protocols.