Dovecot IMAP Basics
Introduction¶
In a self-hosted mail stack, Postfix receives and sends mail (MTA); Dovecot stores it and serves it to users over IMAP/POP3 (MDA + access). It also usually handles authentication for both — Postfix asks Dovecot to verify SMTP AUTH.
Storage formats¶
| Format | Layout | Notes |
|---|---|---|
| Maildir | one file per message, cur/new/tmp dirs |
robust, easy to back up/inspect, slow with huge folders |
| mdbox | few large files, multiple messages each | faster for large mailboxes, needs doveadm purge to reclaim space |
| sdbox | one file per message, dbox metadata | middle ground |
| mbox | one file per folder | legacy, locking pain, avoid |
Maildir is the safe default. mdbox for very large or high-volume mailboxes.
# 10-mail.conf
mail_location = maildir:~/Maildir
# or: mdbox:~/mdbox
namespace inbox {
inbox = yes
mailbox Trash { auto = subscribe; special_use = \Trash }
mailbox Sent { auto = subscribe; special_use = \Sent }
mailbox Junk { auto = subscribe; special_use = \Junk }
}
Authentication: passdb and userdb¶
- passdb — verifies the password (checks against
/etc/dovecot/users, SQL, LDAP, PAM, etc.). - userdb — supplies the user's UID/GID, home, and mail location after auth succeeds.
# 10-auth.conf
disable_plaintext_auth = yes # only over TLS
auth_mechanisms = plain login
# a simple file-based setup (passwd-file)
passdb {
driver = passwd-file
args = scheme=ARGON2ID /etc/dovecot/users
}
userdb {
driver = passwd-file
args = /etc/dovecot/users
default_fields = uid=vmail gid=vmail home=/var/vmail/%d/%n
}
/etc/dovecot/users line: [email protected]:{ARGON2ID}$argon2id$...::::::
For virtual domains, SQL (dovecot-sql.conf.ext) or LDAP passdb/userdb is
common.
The Postfix hand-off (LMTP)¶
Postfix receives mail, then hands local delivery to Dovecot via LMTP (better
than the older deliver binary — supports SIEVE, quota, multiple recipients):
# Dovecot 10-master.conf
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
mode = 0600
user = postfix
group = postfix
}
}
# Postfix main.cf
mailbox_transport = lmtp:unix:private/dovecot-lmtp
virtual_transport = lmtp:unix:private/dovecot-lmtp
Dovecot also runs the auth socket Postfix uses for SMTP AUTH:
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
}
SSL/TLS¶
# 10-ssl.conf
ssl = required
ssl_cert = </etc/letsencrypt/live/mail.example.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.example.com/privkey.pem
ssl_min_protocol = TLSv1.2
IMAPS 993, POP3S 995, or STARTTLS on 143/110. After renewing certs,
doveadm reload (or restart).
SIEVE (server-side filtering)¶
The pigeonhole plugin runs user filter scripts at delivery — sorting, vacation
autoresponders, forwarding. Managed over ManageSieve (port 4190) or a webmail.
Verification and troubleshooting¶
doveconf -n # effective config (like nginx -T)
doveadm auth test [email protected] # test a login without a client
doveadm user [email protected] # show resolved userdb (home, uid, mail location)
doveadm mailbox list -u [email protected]
doveadm quota get -u [email protected]
tail -f /var/log/dovecot.log /var/log/mail.log
- IMAP login fails "Authentication failed" —
doveadm auth testisolates passdb from the client. Wrong scheme prefix in the users file, plaintext auth attempted without TLS (disable_plaintext_auth = yes), or PAM/SQL/LDAP backend unreachable. - Login OK but no mail / "Mailbox doesn't exist" — userdb
mail_locationorhomewrong, or thevmailuser can't read the Maildir (ownership/perms).doveadm usershows what Dovecot computed. - Postfix can't deliver: "connect to private/dovecot-lmtp ... No such file" —
the LMTP
unix_listenerpath is outside Postfix's chroot (/var/spool/postfix/prefix), or Dovecot isn't running, or socket perms. - SMTP AUTH fails in Postfix — the
private/authsocket user/group/mode, andsmtpd_sasl_type = dovecot,smtpd_sasl_path = private/authin Postfix. - "Disk quota exceeded" but there's space — Dovecot quota plugin;
doveadm quota recalc -u user. For mdbox,doveadm purge -u userreclaims deleted-message space. - Certs expired / clients warn —
doveadm reloadafter renewal; checkssl_cert/ssl_keypaths point atfullchain.pem(notcert.pem). - Slow IMAP with big folders (Maildir) — expected; move that user to mdbox,
or ensure indexing (
INDEX/mail_locationwith a separate fast index path).
Related tools and reading¶
- On-site: SMTP test, SSL Certificate Checker, DNS MX Lookup.
- Related posts: Postfix as a null client, Zimbra: common issues and how to fix them.
Stuck on something this site can't fix?Reach out to Prabath directly on LinkedIn.More in Web & Mail Servers
Running BIND 9 as an Authoritative Server
BIND as an authoritative server: zone files, secured AXFR with TSIG, SOA serial rules, and DNSSEC inline-signing. Here's a working master/slave setup.
October 24, 2026Varnish Cache in Front of a Site
Varnish is a caching HTTP accelerator configured in VCL. Here's the request lifecycle, why you strip cookies, how bans work, and grace mode for serving stale during backend trouble.
October 24, 2026Let's Encrypt with Certbot, Including Renewal That Doesn't Break
Getting the first cert is easy; keeping renewal working for years is the part people get wrong. Webroot vs DNS-01, deploy hooks, and the failure modes.
October 24, 2026