Install Dovecot On Debian 12

This blog post will explain how to install Dovecot on Debian 12. This blog post will assume the user is logged in as root.

1. Disable apparmor

aa-teardown
systemctl disable apparmor

2. Update your system. Always refresh package lists before installing. This ensures you have the latest security patches.

apt update && apt upgrade

3. Install Dovecot

apt install dovecot-core dovecot-imapd dovecot-pop3d

4. Configure Dovecot

Type this into the /etc/dovecot/dovecot.conf file.

listen = *, ::
protocols = pop3 imap

ssl = no
ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.pem

ssl_min_protocol = TLSv1.2

disable_plaintext_auth = no

mail_location = maildir:~/Maildir

auth_mechanisms = plain

service pop3-login {
inet_listener pop3 {
port = 110
}
}

service imap-login {
inet_listener imap {
port = 143
}
}

passdb {
driver=pam
}

userdb {
driver=passwd
}

5. Edit PAM file.

Type this into the /etc/pam.d/dovecot file.

auth	required	pam_unix.so	try_first_pass
auth	optional	pam_nologin.so

6. Generate SSL/TLS certificates

openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout /etc/ssl/private/dovecot.pem \
  -out /etc/ssl/certs/dovecot.pem

7. Start and enable the service

systemctl start dovecot
systemctl enable dovecot

8. Check status of dovecot. Ensure no errors are reported.

systemctl status dovecot

Leave a Reply