Dovecot is an open-source IMAP and POP3 Mail Server for Linux and UNIX Operating Systems, which is used to receive incoming emails on a server from Postfix.
We believe you have Postfix preinstalled. The steps to install Dovecot on all Linux OS are listed below.
Install Dovecot
CentOS / AlmaLinux / Rocky Linux # sudo yum install dovecot -y
Ubuntu / Debian: # sudo apt update # sudo apt install dovecot-core dovecot-imapd dovecot-pop3d -y
Configure Dovecot Base Settings
Edit the main config file:
# sudo vi /etc/dovecot/dovecot.conf
Add or modify the following lines:
protocols = imap pop3 mail_location = maildir:~/Maildir
Configure Authentication
# sudo vi /etc/dovecot/conf.d/10-auth.conf
Uncomment or add:
auth_mechanisms = plain login
Set Mail Directory Format
# sudo vi /etc/dovecot/conf.d/10-mail.conf
Add or update this line:
mail_location = maildir:~/Maildir
Configure Postfix SMTP Authentication via Dovecot
# sudo vi /etc/dovecot/conf.d/10-master.conf
Uncomment and modify this section:
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
}
Configure POP3 Settings (Optional)
# sudo vi /etc/dovecot/conf.d/20-pop3.conf
Uncomment or add:
pop3_uidl_format = %08Xu%08Xv pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
Create a Test Mail User
# sudo useradd test # sudo passwd test
Create Mail Directory
# sudo mkdir /home/test/Maildir # sudo chown test:test /home/test/Maildir # sudo chmod -R 700 /home/test/Maildir
Start Dovecot Service
# sudo systemctl start dovecot # sudo systemctl enable dovecot
Configure Postfix to Use Dovecot for SMTP Authentication
# sudo vi /etc/postfix/main.cf
Add or modify the following:
Authentication smtpd_sasl_auth_enable = yes smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_security_options = noanonymous smtpd_sasl_local_domain = $hostname broken_sasl_auth_clients = yes
Restart Postfix
# sudo systemctl restart postfix
Open Required Ports in the Firewall
Open necessary ports for email services # sudo iptables -I INPUT -p tcp -m multiport --dports 110,143,465,587,993,995 -j ACCEPT Save firewall rules (varies by distro) CentOS / RHEL: # sudo service iptables save For firewalld (CentOS 7+): # sudo firewall-cmd --permanent --add-port=110/tcp # sudo firewall-cmd --permanent --add-port=143/tcp # sudo firewall-cmd --permanent --add-port=465/tcp # sudo firewall-cmd --permanent --add-port=587/tcp # sudo firewall-cmd --permanent --add-port=993/tcp # sudo firewall-cmd --permanent --add-port=995/tcp # sudo firewall-cmd --reload For Ubuntu/Debian UFW: # sudo ufw allow 110,143,465,587,993,995/tcp
You now have a fully working Postfix + Dovecot email system with SMTP, IMAP, and POP3 support on your Linux server.
