A Dovecot IMAP setup needs four pieces: a mailbox location, an authentication source, a listener for IMAP and a link to Postfix so incoming mail lands in the same mailboxes. Dovecot reads mail from Maildir directories, lets users log in with their passwords and serves messages to clients such as Thunderbird, Apple Mail or a phone.
This article builds on a working Postfix server and uses Dovecot 2.3 or 2.4 on Debian or Ubuntu. Paths and package names can differ slightly between distributions and between 2.3 and 2.4, so check doveconf -n after each change.
Postfix receives mail and queues it. Dovecot stores and serves it. Two pieces of glue connect them:
Users then read mail with IMAP, which keeps messages on the server and synchronises folders across devices. POP3 downloads and often removes messages, so it suits fewer setups today.
Install the core package plus the IMAP and LMTP components.
Configuration lives in /etc/dovecot/. The main file includes a set of files in conf.d/. Editing the small files in conf.d is clearer than one large file. After each change, validate with:
doveconf -n prints the non-default settings Dovecot actually uses and reports syntax errors.
Maildir stores each message as a separate file, which is safe for concurrent access and quick to back up. Edit /etc/dovecot/conf.d/10-mail.conf.
This must match the home_mailbox = Maildir/ setting you gave Postfix, or mail will be delivered to one place and read from another. Each system user then has ~/Maildir with cur, new and tmp folders. Dovecot creates the folders the first time the user logs in, and Postfix creates them on first delivery.
For many domains and users, real system accounts do not scale. A common design uses virtual users with a single vmail account owning all mail. For a first server, system users are the quickest way to see the whole path work.
Open /etc/dovecot/conf.d/10-auth.conf and set:
With disable_plaintext_auth = yes, Dovecot only accepts passwords over an encrypted connection. This is the reason you must configure TLS before you use the server for real mail. By default, conf.d/auth-system.conf.ext authenticates against system users through PAM, so alice logs in with her Linux password.
If you prefer virtual users, enable auth-passwdfile.conf.ext instead, and keep a password file with hashed values. Generate a hash with Dovecot itself.
Never store plain-text passwords. Use a modern scheme such as ARGON2ID or BLF-CRYPT and paste the full output, including the scheme prefix, into the user file.
In /etc/dovecot/dovecot.conf, list the protocols.
Dovecot listens on port 143 (IMAP with STARTTLS) and 993 (IMAPS, implicit TLS) by default. For the connection to Postfix, edit /etc/dovecot/conf.d/10-master.conf and expose an LMTP socket inside Postfix's spool.
Postfix runs in a chroot for some services, and /var/spool/postfix/private is reachable from there, so the socket must live in that directory. Add an authentication socket the same way for SASL.
Tell Postfix to deliver local mail through LMTP and to use Dovecot for SASL authentication.
The smtpd_recipient_restrictions line is important: it allows authenticated users and local clients, and refuses everyone else who tries to relay. Without reject_unauth_destination, you can create an open relay.
Open the ports in the firewall, then test with a real login.
Check IMAP directly with openssl, which also tests TLS on port 993.
Use the same settings in a mail client: server mail.example.com, port 993, connection security SSL/TLS, username alice. If login fails, read the log.
Typical problems are a wrong mail_location, a permission error on ~/Maildir, plain-text login blocked because TLS is not set up, and a firewall that blocks 993.
Use IMAP for almost everything. It keeps mail on the server and keeps folders and read state in sync across devices. POP3 is only for downloading mail to a single machine.
Port 143 starts unencrypted and upgrades with STARTTLS, and port 993 is encrypted from the first byte. Prefer 993 for clients, and require TLS on both.
Check that disable_plaintext_auth is satisfied by TLS, that the user exists in the configured source and that the hash scheme is valid. doveadm auth test user and the journal usually show the exact reason.
Not for a small private server. For many domains and mailboxes, virtual users with one vmail owner and a database or file are easier to manage and safer.
Install dovecot-core, dovecot-imapd and dovecot-lmtpd, set mail_location = maildir:~/Maildir, enable the imap and lmtp protocols, and choose an authentication source with hashed passwords. Create LMTP and auth sockets in Postfix's private directory, point Postfix at them, then test with doveadm, openssl s_client and a real mail client. Adding a Lets Encrypt certificate then encrypts these logins.