mirror of
https://github.com/docker-mailserver/docker-mailserver
synced 2026-11-21 13:44:26 +01:00
* breaking(dovecot): ship a self-reliant Dovecot configuration DMS imported the config files of Debian's Dovecot package at build time and patched them with `sed` at startup. For the Dovecot Community Edition (CE) it even downloaded Debian's packages only to extract their config. The result depended on whatever the packages shipped, and every feature toggle was an `!include` line that a script had to comment or uncomment. Provide the complete configuration in the repository instead: - `target/dovecot/dovecot.conf` replaces the `10-*`, `15-*`, `20-*` and `90-*` files as well as the `*.inc` files. Everything that is not set there uses Dovecot's built-in defaults. - `target/dovecot/features/` holds the optional parts (passwd-file, LDAP and OAuth2 authentication, quotas, Rspamd learning). Startup copies the ones that are enabled into the empty `/etc/dovecot/conf.d/`, which `dovecot.conf` includes before `local.conf` (`dovecot.cf`). - The scripts only substitute ENV-derived values now; the include toggling and the second `sed` per feature are gone. - Drop the Debian config import and the CE-only download from the build. Breaking: files that users replaced, bind-mounted or patched in `/etc/dovecot/conf.d/` no longer exist (see the changelog for the mapping). Debian's deprecated ManageSieve listener on port 2000 and its `fts_autoindex*` defaults are gone as well. Add tests for the removed port 2000 and for a valid `doveconf -n` with the protocols enabled according to ENV, and adjust the existing tests and fixtures to the new file layout. Rewrite the Dovecot override docs. Closes #4841 * fix(dovecot): load enabled features before user supplied config Features that DMS enables were copied to `conf.d/`, so Dovecot read them in file name order together with user drop-ins. A user file such as `90-custom.conf` was read before `quota.conf` or `auth-ldap.conf`, and the feature silently overrode the user's settings. - copy enabled features to `/etc/dovecot/features.d/` instead, which `dovecot.conf` includes before `conf.d/*.conf` - include the master user passdb before `conf.d/*.conf` as well, so a drop-in can override `auth_master_user_separator` - create `features.d/auth-ldap.conf` with mode 640 (group `dovecot`), as it contains the LDAP bind password - link the changelog entries to the PR, document the always-active master passdb, and adjust docs and tests to the new layout - test that a `conf.d/` file overrides the quota feature, and that `auth-ldap.conf` is not world-readable
302 lines
9.0 KiB
Plaintext
302 lines
9.0 KiB
Plaintext
##
|
|
## Dovecot configuration of docker-mailserver (DMS)
|
|
##
|
|
## DMS owns the complete Dovecot configuration. It does not depend on the files that Debian or the
|
|
## Dovecot Community Edition packages ship. Dovecot's built-in defaults apply to all settings that are
|
|
## not mentioned here.
|
|
##
|
|
## - Settings that DMS scripts change at startup (based on ENV) are written uncommented, so that
|
|
## `sedfile` can match them. Do not rename or comment them out without adjusting the scripts.
|
|
## - Optional features live in `/etc/dovecot/features/` and are copied to `/etc/dovecot/features.d/` when enabled.
|
|
## - `features.d/*.conf` (enabled features), `conf.d/*.conf` (user supplied drop-ins) and `local.conf`
|
|
## (from `dovecot.cf`) are included at the end in this order, so they can extend and override this file,
|
|
## and user supplied files can override the features.
|
|
##
|
|
## ref: https://doc.dovecot.org/main/core/config/quick.html
|
|
##
|
|
|
|
# Keep the defaults of the 2.4.0 release: newer 2.4.x releases (Dovecot CE) then behave like Debian's 2.4.1.
|
|
dovecot_config_version = 2.4.0
|
|
dovecot_storage_version = 2.4.0
|
|
|
|
##
|
|
## Protocols
|
|
##
|
|
|
|
# LMTP is always required for delivery. IMAP, POP3 and ManageSieve are enabled via
|
|
# `ENABLE_IMAP`, `ENABLE_POP3` and `ENABLE_MANAGESIEVE` (`_setup_dovecot` and `_setup_dovecot_sieve`).
|
|
# Dovecot's default listeners (143, 993, 110, 995, 4190) apply to the enabled protocols.
|
|
protocols {
|
|
lmtp = yes
|
|
imap = no
|
|
pop3 = no
|
|
sieve = no
|
|
}
|
|
|
|
# `DOVECOT_INET_PROTOCOLS` (`_setup_dovecot_inet_protocols`)
|
|
listen = *, ::
|
|
|
|
##
|
|
## Logging
|
|
##
|
|
|
|
# Log unsuccessful authentication attempts and the reasons why they failed.
|
|
auth_verbose = yes
|
|
|
|
# In case of password mismatches, log a (truncated) hash of the attempted password.
|
|
auth_verbose_passwords = sha1:6
|
|
|
|
##
|
|
## Authentication
|
|
##
|
|
|
|
# The passdb and userdb come from the features in `features.d/`: `auth-passwdfile.conf` or `auth-ldap.conf`
|
|
# (`ACCOUNT_PROVISIONER`), and `auth-oauth2.conf` (`ENABLE_OAUTH2`).
|
|
auth_mechanisms {
|
|
plain = yes
|
|
login = yes
|
|
}
|
|
|
|
# Require TLS for plaintext authentication mechanisms, unless the connection is trusted.
|
|
# `SSL_TYPE=''` sets this to `yes` (see `_setup_ssl`).
|
|
auth_allow_cleartext = no
|
|
|
|
##
|
|
## TLS
|
|
##
|
|
|
|
# `required` when IMAP or POP3 is enabled, `no` with `SSL_TYPE=''`
|
|
ssl = yes
|
|
|
|
# PEM encoded X.509 SSL/TLS certificate and private key.
|
|
# These [snakeoil files actually exist](https://askubuntu.com/questions/396120/what-is-the-purpose-of-the-ssl-cert-snakeoil-key), but shouldn't ever be used in production!
|
|
# As `SSL_TYPE` env is required by docker-mailserver, these "snakeoil" files will be replaced on container startup.
|
|
ssl_server_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
|
|
ssl_server_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
|
|
|
|
# Fallback/Hybrid cert support. docker-mailserver will enable these when using ENV vars `SSL_ALT_CERT_PATH` and `SSL_ALT_KEY_PATH`.
|
|
#ssl_server_alt_cert_file = /path/to/alternative/cert.pem
|
|
#ssl_server_alt_key_file = /path/to/alternative/key.pem
|
|
|
|
# Both are set by `TLS_LEVEL` (see `_setup_tls_level`).
|
|
ssl_min_protocol = TLSv1.2
|
|
ssl_cipher_list = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
|
|
|
|
# ref: https://doc.dovecot.org/main/core/summaries/settings.html#ssl_server_prefer_ciphers
|
|
ssl_server_prefer_ciphers = server
|
|
|
|
##
|
|
## Mailboxes
|
|
##
|
|
|
|
# `DOVECOT_MAILBOX_FORMAT` changes `mail_driver` and `mail_home` (`_setup_dovecot`).
|
|
# ref: https://doc.dovecot.org/main/core/config/mail_location.html
|
|
mail_driver = maildir
|
|
mail_path = /var/mail/%{user | domain}/%{user | username}
|
|
mail_home = /var/mail/%{user | domain}/%{user | username}/home
|
|
|
|
# Group to enable temporarily for privileged operations. Currently this is
|
|
# used only with INBOX when either its initial creation or dotlocking fails.
|
|
mail_privileged_group = docker
|
|
|
|
# Mailbox list indexes optimize IMAP STATUS commands. The quota `count` driver also relies on them.
|
|
# ref: https://doc.dovecot.org/main/core/plugins/quota.html#driver-count
|
|
mailbox_list_index = yes
|
|
|
|
# mailserver/docker-mailserver:
|
|
# Seen dovecot-sieve is always enabled, setting `maildir_stat_dirs = yes` permits
|
|
# to avoid `/var/mail/domain.tld/user/.dovecot.sieve` (symlink) to be treated as a directory (default behavior).
|
|
# According to https://github.com/Mailu/Mailu/issues/143#issuecomment-274596931, there is no noticeable impact when this is enabled.
|
|
maildir_stat_dirs = yes
|
|
|
|
# Add `$HasAttachment` / `$HasNoAttachment` keywords to mails when they are saved.
|
|
# Dovecot 2.4.2 changed the default to `add-flags` for maildir and dbox. The upgrade notes say this
|
|
# only applies with `dovecot_config_version = 2.4.2`, but LMTP also applies it with `2.4.0`.
|
|
# DMS deliberately keeps it disabled, so builds with Debian's Dovecot (2.4.1) and with the
|
|
# Dovecot CE packages (2.4.2+) behave the same. This is a choice, not a fix: with the keyword,
|
|
# maildir stores new mail in `cur/` instead of `new/`, which is still valid and still unread.
|
|
mail_attachment_detection_options =
|
|
|
|
# Mailboxes that are widely used are created and subscribed automatically.
|
|
# ref: https://doc.dovecot.org/main/core/config/namespace.html
|
|
namespace inbox {
|
|
inbox = yes
|
|
|
|
mailbox Drafts {
|
|
auto = subscribe
|
|
special_use = \Drafts
|
|
}
|
|
mailbox Junk {
|
|
auto = subscribe
|
|
special_use = \Junk
|
|
}
|
|
mailbox Trash {
|
|
auto = subscribe
|
|
special_use = \Trash
|
|
}
|
|
mailbox Sent {
|
|
auto = subscribe
|
|
special_use = \Sent
|
|
}
|
|
}
|
|
|
|
##
|
|
## Delivery (LMTP and LDA)
|
|
##
|
|
|
|
# NOTE: While Postfix delivers to Dovecot via LMTP, LDA may be used by other services
|
|
# like Getmail (configured to use `/usr/lib/dovecot/deliver`).
|
|
# Both values are set from `POSTMASTER_ADDRESS` and `HOSTNAME` (`_setup_dovecot`).
|
|
# The placeholders use the reserved `.invalid` TLD, so they never equal the value that replaces them.
|
|
postmaster_address = postmaster@example.invalid
|
|
hostname = mail.example.invalid
|
|
|
|
lda_mailbox_autocreate = yes
|
|
lda_mailbox_autosubscribe = yes
|
|
|
|
protocol lda {
|
|
mail_plugins {
|
|
sieve = yes
|
|
}
|
|
}
|
|
|
|
protocol lmtp {
|
|
mail_plugins {
|
|
sieve = yes
|
|
}
|
|
}
|
|
|
|
##
|
|
## Sieve
|
|
##
|
|
## ref: https://doc.dovecot.org/main/core/plugins/sieve.html
|
|
##
|
|
|
|
# Every `*.sieve` file in these directories runs, in file name order.
|
|
# ref: https://doc.dovecot.org/main/core/plugins/sieve.html#script-storage-types
|
|
sieve_script global_before {
|
|
type = before
|
|
path = /usr/lib/dovecot/sieve-global/before
|
|
}
|
|
|
|
sieve_script global_after {
|
|
type = after
|
|
path = /usr/lib/dovecot/sieve-global/after
|
|
}
|
|
|
|
# ref: https://doc.dovecot.org/main/core/config/sieve/overview.html#extensions
|
|
sieve_extensions {
|
|
special-use = yes
|
|
vnd.dovecot.pipe = yes
|
|
vnd.dovecot.filter = yes
|
|
}
|
|
|
|
# Extensions only available in administrator-controlled (global) scripts.
|
|
# `editheader` is enabled when `SPAM_SUBJECT` is set (`_setup_spam_subject`).
|
|
sieve_global_extensions {
|
|
editheader = no
|
|
}
|
|
|
|
# ref: https://doc.dovecot.org/main/core/plugins/sieve.html#sieve_plugins
|
|
# https://doc.dovecot.org/main/core/plugins/imap_sieve.html
|
|
# https://doc.dovecot.org/main/core/plugins/sieve_extprograms.html
|
|
sieve_plugins {
|
|
sieve_imapsieve = yes
|
|
sieve_extprograms = yes
|
|
}
|
|
|
|
# Directories with the programs for the `vnd.dovecot.pipe` and `vnd.dovecot.filter` extensions.
|
|
# ref: https://doc.dovecot.org/main/core/plugins/sieve_extprograms.html#sieve_pipe_bin_dir
|
|
sieve_pipe_bin_dir = /usr/lib/dovecot/sieve-pipe
|
|
sieve_filter_bin_dir = /usr/lib/dovecot/sieve-filter
|
|
|
|
##
|
|
## Services
|
|
##
|
|
|
|
service auth {
|
|
# Used by `dovecot-lda`, `doveadm`, and the Dovecot processes that run as `docker`.
|
|
unix_listener auth-userdb {
|
|
mode = 0666
|
|
user = docker
|
|
group = docker
|
|
}
|
|
|
|
unix_listener auth-master {
|
|
mode = 0600
|
|
user = docker
|
|
group = docker
|
|
}
|
|
|
|
# Postfix smtp-auth
|
|
unix_listener /dev/shm/sasl-auth.sock {
|
|
mode = 0660
|
|
user = postfix
|
|
group = postfix
|
|
}
|
|
}
|
|
|
|
# Postfix delivers mail via this socket.
|
|
service lmtp {
|
|
unix_listener lmtp {
|
|
mode = 0660
|
|
group = postfix
|
|
}
|
|
}
|
|
|
|
# `chroot` environments are not strictly needed and can cause problems:
|
|
# https://github.com/docker-mailserver/docker-mailserver/pull/3208#pullrequestreview-1366106516
|
|
service anvil {
|
|
chroot =
|
|
}
|
|
|
|
service ipc {
|
|
chroot =
|
|
}
|
|
|
|
service imap-login {
|
|
chroot =
|
|
}
|
|
|
|
service pop3-login {
|
|
chroot =
|
|
}
|
|
|
|
service managesieve-login {
|
|
chroot =
|
|
}
|
|
|
|
service submission-login {
|
|
chroot =
|
|
}
|
|
|
|
service imap-urlauth-login {
|
|
chroot =
|
|
}
|
|
|
|
##
|
|
## Includes
|
|
##
|
|
|
|
# Features enabled by DMS (copied from `/etc/dovecot/features/` at startup).
|
|
!include_try features.d/*.conf
|
|
|
|
# Master user passdb (`dovecot-masters.cf`). It must be listed after the passdb of the user accounts (`features.d/`).
|
|
# ref: https://doc.dovecot.org/main/core/config/auth/master_users.html
|
|
auth_master_user_separator = *
|
|
|
|
passdb passdb-master {
|
|
master = yes
|
|
driver = passwd-file
|
|
passwd_file_path = /etc/dovecot/masterdb
|
|
auth_username_format = %{user | lower}
|
|
default_password_scheme = SHA512-CRYPT
|
|
result_success = continue
|
|
}
|
|
|
|
# User supplied drop-ins, they are read after the features and can override them.
|
|
!include_try conf.d/*.conf
|
|
|
|
# User supplied `dovecot.cf`
|
|
!include_try local.conf
|