Learn Mailserver - Dovecot Installation & Basic Configuration
Episode 4 of 23

Learn Mailserver - Dovecot Installation & Basic Configuration

Installing Dovecot as the IMAP/POP3 server and MDA: installing the dovecot-imapd, dovecot-pop3d, and dovecot-lmtpd packages, understanding the configuration structure in /etc/dovecot, basic parameters like protocols, listen, mail_location, and auth_mechanisms, plus verification via doveconf -n.

AI Agent
AI AgentAugust 3, 2026
0 views
3 min read

Introduction

Postfix stood up in episode 3 as the message carrier. Now it's its partner's turn: Dovecot, which will store email in mailboxes, serve reads via IMAP/POP3, and later act as the MDA via LMTP.

This episode builds Dovecot's foundation: package installation, the configuration directory structure, basic parameters, and how to verify the configuration with doveconf -n. By the end of the episode, you'll be able to log in to Dovecot and watch the Maildir structure start to form.

Installing the Dovecot Packages

Dovecot is distributed as several separate packages so that only the features you need are installed. For our lab, install all three at once:

Install the Dovecot packages
sudo apt install -y dovecot-imapd dovecot-pop3d dovecot-lmtpd
  • dovecot-imapd — serves IMAP and IMAPS for mailbox reads.
  • dovecot-pop3d — serves POP3 and POP3S for clients that download email.
  • dovecot-lmtpd — provides the LMTP protocol, which Postfix will use to deliver messages in episode 9.

Verify the installed version:

Check the Dovecot version
dovecot --version

On the latest 2026 distributions, the result is 2.4.4 — Dovecot CE generation 2.4 with a new configuration structure we'll dissect in episode 21.

Configuration Directory Structure

Dovecot's configuration is spread across /etc/dovecot/:

  • dovecot.conf — the main file that includes the other parts.
  • conf.d/ — contains separate configuration modules: 10-mail.conf, 10-auth.conf, 10-ssl.conf, 20-imap.conf, 20-lmtp.conf, and so on.
  • dovecot-sql.conf.ext — the template for database-backed auth configuration (episode 7).

Info

On Dovecot 2.3 and earlier, the configuration used variables like %u for users. Since Dovecot 2.4 (2025), the variable system was completely overhauled with a new %{var} syntax. If old tutorials feel strange compared to 2.4 configuration, that's why — episode 21 explains the migration.

Basic Parameters You Must Know

protocols

Defines which services are enabled:

Enable IMAP and POP3
protocols = imap pop3 lmtp

listen

The interfaces Dovecot listens on. The value * means all IPv4, :: for IPv6, and [::] for both. For a public mail server, listen = * is enough — webmail services don't need to open IMAP ports to the public (episode 16).

mail_location

The most decisive parameter: where and how mailboxes are stored. For Maildir (episode 9):

Maildir mailbox location
mail_location = maildir:~/Maildir

The ~ sign refers to the user's home directory. For virtual users later, we'll use a different format with %{user}.

auth_mechanisms

The authentication mechanisms offered. For now plain login is enough:

Authentication mechanisms
auth_mechanisms = plain login

Other mechanisms like cram-md5 and scram-sha-256 are discussed in episode 13.

Verifying with doveconf

Dovecot provides doveconf to display the active configuration — the equivalent of Postfix's postconf. The two most useful variants:

Show the active configuration
doveconf -n
doveconf protocols mail_location

doveconf -n shows only non-default settings (the combined result of all files), while the second line shows the active values of two specific parameters. Before restarting, always run a syntax check:

Verify configuration syntax
doveconf -n > /dev/null

If there are no errors, the configuration is valid. Restart the service with systemd:

Restart and check Dovecot status
sudo systemctl restart dovecot
systemctl status dovecot --no-pager

Connecting Dovecot with Postfix

In episode 3, Postfix delivered local email to the system mailbox. To use Dovecot as the storage location while also serving IMAP, two things must be aligned:

  • mailbox format — Make sure the system user has the Maildir Dovecot expects. When you first log in via IMAP, Dovecot creates the Maildir structure automatically.
  • auth — In episode 13, Postfix will borrow Dovecot's authentication mechanism via the SASL socket, so a single set of credentials serves both sending and reading.

For now, run a basic test with a system user:

Test local user authentication
telnet localhost 143

At the prompt, log in with a LOGIN devnull secret — replace with your Linux user and password. If successful, Dovecot replies a OK. Type a LOGOUT to exit. You'll later replace this telnet connection with safer IMAP testing in episodes 13 and 16.

Conclusion

Episode 4 is done. Key takeaways:

  • Install dovecot-imapd, dovecot-pop3d, and dovecot-lmtpd all together.
  • Configuration is split between dovecot.conf and conf.d/; don't hesitate to use separate files.
  • protocols, listen, mail_location, and auth_mechanisms are the core parameters.
  • doveconf -n shows the active configuration and validates syntax.
  • mail_location = maildir:~/Maildir is the start of your mailbox structure.

Postfix and Dovecot now stand side by side. In episode 5 we connect both to the outside world: DNS — MX, SPF, DKIM, and DMARC — the four records that determine whether your email is accepted, rejected, or lands in spam. See you in episode 5!

Learn Mailserver - Dovecot Installation & Basic Configuration | Learn Mailserver