Dovecot is a secure, open-source IMAP and POP3 server that works alongside Postfix to deliver email to mail clients. This guide installs and configures Dovecot IMAP on Ubuntu 24.04 LTS.
Tested and valid on:
- Ubuntu 24.04 LTS
Prerequisites
- Ubuntu 24.04 LTS server
- Postfix installed and configured
- A domain name with MX records
- A user with sudo privileges
Step 1 – Install Dovecot
Install Dovecot with IMAP and LMTP support:
sudo apt update
sudo apt install dovecot-core dovecot-imapd dovecot-lmtpd -y
Step 2 – Configure Dovecot Mail Location
Edit the main Dovecot config:
sudo nano /etc/dovecot/dovecot.conf
Set the mail location:
mail_location = maildir:~/Maildir
Step 3 – Configure Authentication
Edit the auth config:
sudo nano /etc/dovecot/conf.d/10-auth.conf
Set:
disable_plaintext_auth = yes
auth_mechanisms = plain login
Step 4 – Configure the Mailbox
Edit the mail config:
sudo nano /etc/dovecot/conf.d/10-mail.conf
Set:
mail_location = maildir:~/Maildir
Step 5 – Configure SSL
Enable SSL for IMAP:
sudo nano /etc/dovecot/conf.d/10-ssl.conf
Set:
ssl = required
ssl_cert = </etc/ssl/certs/mysite.crt
ssl_key = </etc/ssl/private/mysite.key
Step 6 – Configure Postfix to Use Dovecot LMTP
Edit /etc/postfix/main.cf:
mailbox_transport = lmtp:unix:private/dovecot-lmtp
Edit /etc/dovecot/conf.d/10-master.conf to enable the LMTP socket for Postfix.
Step 7 – Restart and Test
Restart both services:
sudo systemctl restart dovecot postfix
Test IMAP connectivity:
openssl s_client -connect localhost:993
Conclusion
Dovecot is now handling IMAP delivery on Ubuntu 24.04 LTS. Users can connect with email clients like Thunderbird or Apple Mail using IMAP with SSL/TLS on port 993.