Skip to content

feat(dovecot): upgrade to Dovecot 2.4 - #335

Merged
DavidePrincipi merged 10 commits into
mainfrom
dovecot-2.4
Nov 10, 2026
Merged

DavidePrincipi merged 10 commits into
mainfrom
dovecot-2.4

Conversation

@DavidePrincipi

@DavidePrincipi DavidePrincipi commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

The Mail application runs Dovecot 2.3, which is no longer developed. This PR moves it to Dovecot 2.4, with an automatic migration of existing installations during the normal update. NethServer/dev#8267

All Mail images now build from Alpine 3.24: Dovecot 2.4.5, Postfix 3.11, Rspamd 4.0 with Redis 8.8, ClamAV 1.4.6. Mailboxes, indexes, full-text search (FTS) indexes, quotas, shared folders and Sieve filters are used as they are. Dovecot writes them in its 2.4.5 formats, which changes only the thread index used by the IMAP THREAD command: it is rebuilt automatically the next time a client needs it. Custom Dovecot settings in local.conf.d written with the old syntax cannot be loaded by Dovecot 2.4: they are disabled with a warning, so the mail server still starts. The release is meant to ship as Mail 2.0: going back to the previous release after the update is not supported.

  • The Dovecot configuration is rewritten for 2.4 and keeps the 2.3 behavior where 2.4 changed defaults: empty parent folders are still listed, folder names with dots keep their on-disk names, clear-text login without TLS is still allowed from localhost and trusted networks only, FTS keeps the language used by 2.3, and the last delivered message can still exceed the quota by 10% of the limit.
  • Per-user quotas are read from the existing files by a small Lua script, because 2.4 removed the previous lookup method. Actions address the quota and spam retention data by name, as 2.4 requires.
  • If the files in local.conf.d break the configuration, all of them are renamed to hidden .<name>.<timestamp>.err files. A new fact, dovecot_custom_config_rejected_count, counts these rejections.
  • With Rspamd 4.0, links found inside attachments (for example PDF files) are checked too. Two older bugs found by the tests are fixed as well: Postfix is reloaded after authentication settings change, and spam learning works when the Rspamd password starts with "-".

How to test

  • Install the current Mail release, create users, a shared folder, a public mailbox, a custom quota, a Sieve filter and a custom file in local.conf.d.
  • Update to the images of this PR and check mail delivery, login, quotas (a message larger than the quota is rejected), shared folders, public mailboxes, Sieve filters and full-text search. A custom file with the old syntax is renamed and a warning is logged.
  • Run the Robot test suite, in both the install and the update scenarios.

Generated by Claude Code:claude-opus-5-5 with nethserver-pr

@DavidePrincipi DavidePrincipi self-assigned this Nov 3, 2026
@DavidePrincipi
DavidePrincipi marked this pull request as ready for review November 5, 2026 16:47
Comment thread dovecot/etc/dovecot/uquota.lua Resolved
Build the mail-dovecot image from Alpine 3.24, which ships Dovecot
2.4.5 and the fts-flatcurve plugin, and rewrite the configuration in
the 2.4 syntax. The package provides no base configuration anymore,
so the template now renders the whole dovecot.conf.

Keep the 2.3 behavior where 2.4 changed defaults: \NoSelect mailboxes
are listed, mailbox names escaped by listescape are read as before,
and FTS uses "da" as default language like 2.3 did. Clear-text
authentication is still allowed from localhost and trusted networks
only: with "ssl = yes" Dovecot 2.4 treats them as secured connections,
so they need no special setting. The storage version stays at 2.3, so
the existing data keeps its formats.

The dict userdb is gone in 2.4: a Lua userdb reads the custom quota
from the existing uquota dict files. Actions and scripts address the
quota and spam retention dicts by filter name, as the doveadm dict
commands no longer accept dict URIs. Existing mailboxes, indexes,
FTS indexes and dict files are used as they are.

If the local.conf.d snippets break the configuration, like those
written for 2.3, they are all rejected: renamed to hidden
.<name>.<timestamp>.err files with a warning, so Dovecot can start.
The check runs on each configuration reload and leaves no state
behind. The dovecot_custom_config_rejected_count fact counts the
rejections.

Assisted-by: Claude Code:claude-opus-5-5
Add tests for the Dovecot features whose configuration the module
generates: shared seen flags in both modes, user listing, custom quota
and spam retention dicts, mailbox name escaping, FTS default language
and lookup, and the rejection of invalid local.conf.d snippets.

Check also the IMAP privilege of a user who is not a master user.

Assisted-by: Claude Code:claude-opus-5-5
Align the postfix, rspamd and clamav images to the Alpine release of
the dovecot image. Postfix moves to 3.11, Rspamd to 4.0 with Redis
8.8, ClamAV to 1.4.6.

With Rspamd 4.0 URLs found in attachment contents, like PDF files,
are checked too.

Assisted-by: Claude Code:claude-opus-5-5
Postfix smtpd processes keep their connection to the Dovecot auth
process started before a Dovecot reload, and that process still has
the previous configuration. After enabling or disabling a mailbox, or
changing the master users, SMTP authentication kept the old behavior
until the smtpd processes were recycled.

Reload Postfix after Dovecot, so the smtpd processes connect to the
new auth process.

Assisted-by: Claude Code:claude-opus-5-5
rspamc takes an optional argument for -P: a separate argument starting
with "-" is not used as the password, and rspamc fails with "Invalid
password". The generated Rspamd password can start with "-", so on
such installations the Junk folder spam/ham learning never reached
Rspamd, and the bypass rules tests failed.

Use --password=VALUE, which takes any value.

Assisted-by: Claude Code:claude-opus-5-5
Dovecot 2.3 let the last delivered message exceed the quota limit by
10% of the limit. Dovecot 2.4 replaced it with a fixed 10M grace, so
small quotas were no longer enforced: a 4.6 MB message was accepted
for a 2 MiB mailbox. Dovecot 2.4 does not accept a percentage, so set
the grace to 10% of the default limit and of each custom limit.

Assisted-by: Claude Code:claude-opus-5-5
Raise dovecot_storage_version from 2.3.21 to 2.4.5. Going back to the
previous release is not supported anyway, so there is no reason to
keep the data readable by Dovecot 2.3.

Up to 2.4.5 the only changed format is the v2 thread index used by
the IMAP THREAD command: Dovecot rebuilds it the next time a client
threads a mailbox. No other data is converted.

Assisted-by: Claude Code:claude-opus-5-5
Robot strips the trailing newline from command output, so the "og\n"
check passed even if "og" was the last token. Match whole words at the
end of a line instead.

Assisted-by: Claude Code:claude-sonnet-5-5
The Postfix reload added after the Dovecot reload became the last
command of the step, so its exit code hid a failed Dovecot reload and
the action reported success. Stop at the first failing command.

Assisted-by: Claude Code:claude-opus-5-5
The doveadm dict commands address the custom quota dict by the name of
its settings block, quota_clone, not by the dict name uquota, which is
rejected as an unknown filter.

Assisted-by: Claude Code:claude-opus-5-5

@stephdl stephdl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the latest images on a node: login on IMAP, POP3 and SMTP from trusted and untrusted networks, master users, custom quota and FTS. All good, thanks.

@DavidePrincipi
DavidePrincipi merged commit bcdc4e3 into main Nov 10, 2026
5 checks passed
@DavidePrincipi
DavidePrincipi deleted the dovecot-2.4 branch November 10, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants