Skip to content

Mail: upgrade to Dovecot 2.4 #8267

In progress
In progress

Description

@DavidePrincipi

The Mail application runs Dovecot 2.3, which is no longer developed: new features and fixes go into Dovecot 2.4. Dovecot 2.4 configuration is not compatible with 2.3, so the upgrade needs a migration of every existing mail server, which must happen during the normal application update, without manual steps and without losing messages or settings.

Proposed solution

  • Build the Mail application image with Dovecot 2.4 and rewrite its configuration for the new syntax.
  • Migrate existing installations during the application update: generated configuration, admin customizations where supported, Sieve filters, quotas, shared folders, and the master user used by other applications.
  • Keep mailbox data in place: no conversion of mail storage is expected, but indexes may be rebuilt.
  • Check every integration that talks to Dovecot: Postfix SASL authentication, Rspamd spam training, Imapsync, WebTop, Roundcube, backup and restore, cloning and moving the application, and restore of a Dovecot 2.3 backup on the new version.
  • Review features removed in 2.4 that we may use, and document any change of behavior in the release notes.

Alternative solutions

  • Stay on Dovecot 2.3 until a new major Mail version that requires a manual migration: not acceptable, as the upgrade must be automatic for existing installations.

Additional context

SSO support for webmail clients (#8264) should be implemented after this upgrade.

Before changing defaults, PhoneHome data can tell how many installations run the Mail application and which versions.

See also

Activity

  1. added
    milestone goal 👑
    on Oct 21, 2026
  2. moved this from ToDo to In Progress in NethServeron Nov 2, 2026
  3. changed the issue type fromtoon Nov 3, 2026
  4. DavidePrincipi commented on Nov 10, 2026

    @DavidePrincipi
    MemberAuthor

    Build: ghcr.io/nethserver/mail:2.0.0-beta.1 (NethServer/ns8-mail#335). It ships as Mail 2.0: going back to 1.x after the update is not supported, so test on a cluster that can be thrown away, or take a backup first.

    Install it from the testing repository, or update an existing instance on the cluster leader, replacing the instance name:

    update-module ghcr.io/nethserver/mail:2.0.0-beta.1 mail1
    

    Test cases

    Before the update, on Mail 1.9.x, prepare some users with messages, a folder shared with another user, a public mailbox, a custom quota for one user, a Sieve filter and a file in local.conf.d (for example a plugin { } block).

    1. Update: Dovecot reports 2.4.5 and all the Mail containers are running.
    2. Login: IMAP, POP3 and SMTP authenticated submission work for every user. Clear-text login without TLS works only from localhost and trusted networks.
    3. Delivery: messages from outside reach the user mailboxes, and the Sieve filters still move them to the right folder. ManageSieve shows the existing scripts.
    4. Quota: the custom quota is kept. A message bigger than the limit plus 10% is rejected, as before.
    5. Folders: shared folders and public mailboxes keep their permissions. Empty parent folders are still listed, and folder names with dots keep their names.
    6. Full-text search: searching message bodies finds both old and new messages.
    7. Custom configuration: a local.conf.d file with the 2.3 syntax is renamed to .<name>.<timestamp>.err and a warning is logged, but Dovecot still starts. The dovecot_custom_config_rejected_count fact counts the rejections.
    8. Spam training: moving a message into or out of the Junk folder trains Rspamd.
    9. Master users and disabled mailboxes: changing them takes effect for both IMAP and SMTP authentication, without restarting the services.
    10. Integrations: check WebTop, Roundcube and Imapsync with the updated server, and backup/restore, clone and move of the Mail application, including the restore of a backup taken with Mail 1.9.x.

    Cases 1-7 were checked on a test cluster updated from 1.9.3. The Robot test suite passes in both the install and the update scenarios.

  5. added
    testing
    on Nov 10, 2026
  6. moved this from In Progress to Testing in NethServeron Nov 10, 2026
  7. added 2 commits that reference this issue on Nov 11, 2026
  8. DavidePrincipi commented on Nov 11, 2026

    @DavidePrincipi
    MemberAuthor

    QA on a cluster where a Mail 1.9 backup of a production system was restored, then updated from 1.9.3 to 2.0.0-beta.1. WebTop and Roundcube were restored from the same backup.

    Old local.conf.d/myoverride.conf (service imap-login { process_limit = 500 }): kept, not renamed to .err, and applied: doveconf -h service/imap-login/process_limit returns 500 (default 400). No rejected snippets.

    8. Spam training ✅ The spam folder of this system is junkmail (migrated from NS7).

    • INBOX → junkmail: Rspamd learned message as spam.
    • junkmail → INBOX: Rspamd learned message as ham (unlearn=true, the spam training is reversed).
    • A message Bayes already rated as spam (99.91%) is not learned again, as expected from Rspamd.

    9. Master users and disabled mailboxes ✅ New IMAP (143) and SMTP submission (587) logins after each action:

    Step user user*master
    Baseline IMAP OK, SMTP OK fail, fail
    set-master-users adds the user OK, OK OK, OK
    set-master-users removes the user OK, OK fail, fail
    set-mailbox-enabled false fail, fail fail, fail
    set-mailbox-enabled true OK, OK fail, fail

    Dovecot and Postfix MainPIDs did not change: the reload is enough.

    10. Integrations (partial)

    • WebTop and Roundcube restored from the 1.9 backup: login, INBOX and folder navigation, threading views are OK.
    • Imapsync 1.3.4 ✅ New instance configured with the updated Mail. A task copies a migrated user's mailbox (16k messages, 11 folders) from the same Dovecot 2.4 server, over STARTTLS, to a new empty user. The local login is <user>*vmail.
      • Task validation: a wrong remote password returns bad_user_credentials, the right one creates the task.
      • First sync: exit code 0. Every folder has the same messages and unseen counts on both sides. Names with dots (Liste/Samba.org) are kept, and Shared/ is not copied.
      • Incremental sync (--maxage=1): a new message is copied once. A second run copies nothing.
      • Sieve (INBOX-only mode, --sievedelivery2): a new message is filed into the folder chosen by the local user's Sieve script.
      • Cron (1m): a new message is copied by the timer within a minute.
      • --maxage searches by SENTSINCE, so a message without a Date: header is never picked up by an incremental run. Dovecot answers SENTSINCE correctly: this is Imapsync behavior, not a regression.
      • Not tested: quota on the local user. Not a Mail issue: on the test host the FQDN resolves to 127.0.1.1 in /etc/hosts, so using the node's own FQDN as remote host fails inside the container with Check_hostname_or_tcp_port. I used the node IP instead.
    • Clone and move of the Mail application: still to do.

    Side notes:

    • get-facts hung for more than 90s on this system; to be investigated.
    • Logins impersonated by vmail (WebTop) are logged as imap-postlogin: Error: <5>impersonated login .... It also happens with 1.9, not a regression.
  9. DavidePrincipi commented on Nov 11, 2026

    @DavidePrincipi
    MemberAuthor

    The testing image ghcr.io/nethserver/mail:2.0.0-beta.2 is available. It adds two changes for this issue:

    Test cases for verification:

    • Run api-cli run module/mail1/get-facts: dovecot_default_process_limit is 400. Set DOVECOT_DEFAULT_PROCESS_LIMIT=1000 in the module dovecot.env, restart Dovecot and run it again: the value is 1000.
    • Turn quota off with runagent -m mail1 python3 -c 'import agent ; agent.set_env("DOVECOT_QUOTA_MB", "")' and runagent -m mail1 systemctl --user reload dovecot. The Mailboxes page and list-user-mailboxes load and show no quota, and the facts report no mailbox error.
    • Set a quota again from the web interface: quota information comes back in the mailbox list.

    Automated coverage: tests/40__api/90__facts.robot (Collect facts) and tests/40__api/30__mailboxes.robot (List user mailboxes with the quota plugin disabled).

  10. removed
    testing
    on Nov 24, 2026
  11. moved this from Testing to In Progress in NethServeron Nov 24, 2026
  12. added a commit that references this issue on Nov 26, 2026
  13. added
    testing
    on Nov 26, 2026
  14. DavidePrincipi commented on Nov 26, 2026

    @DavidePrincipi
    MemberAuthor

    NethServer/ns8-mail#356 changes how disabled mailboxes are stored and applied in Mail 2.0. It is available in Mail 2.0.0-beta.5 from the testing repository.

    Test cases

    Cases marked with ✋ are not covered by the automated test suite, or only in part: they need a manual check.

    1. Disable and enable several mailboxes in a row from the Mail UI: each change applies at once, and Postfix and Dovecot are not reloaded (journalctl --since -5min shows no reload). ✋
    2. API: set-mailbox-enabled with {"user":"alice","enabled":false,"udesc":"Printer account"}; list-user-mailboxes returns alice with enabled: false and that udesc.
    3. A disabled mailbox is still listed in the Mailboxes page with its quota, and its contents are kept. ✋ (the listing is covered; quota and contents are not)
    4. A master user can still log in to the disabled mailbox, e.g. alice*vmail. ✋
    5. Update from Mail 1.9.x with disabled mailboxes: they stay disabled, and the DOVECOT_DISABLED_USERS variable is removed from the module environment. ✋
    6. Fresh install: Postfix and Dovecot start, and systemctl --user status pcdb-init shows that the configuration database was initialized. (covered implicitly: the suite installs Mail and starts the services)
    7. Back up, remove and restore Mail with a disabled mailbox: pcdb-init loads the backup dump before Postfix and Dovecot start, and the mailbox stays disabled during and after the restore. ✋
    8. Import from NethServer 7 with a user whose mail service is disabled: the mailbox is disabled in Mail 2.0, with a description of why. ✋
  15. moved this from In Progress to Testing in NethServeron Nov 26, 2026
  16. DavidePrincipi commented on Nov 27, 2026

    @DavidePrincipi
    MemberAuthor

    QA of Mail 2.0.0-beta.6 on Rocky Linux 9.8, core 3.25.1, OpenLDAP user domain. Only the cases marked ✋ in the beta.5 comment were checked by hand.

    Update from 1.9.3 ✅ All containers running, Dovecot 2.4.5. Disabled mailboxes and the public folders quota are migrated without manual steps (details in #8185 and #8305).

    Disabled mailboxes (2.0.0-beta.5 test cases)

    1. ✅ Disable and enable several mailboxes in a row (three mailboxes, three times): each change applies at once, and the Postfix and Dovecot main PIDs do not change, with no reload in the journal. Checked with the set-mailbox-enabled API action, which the UI calls; the UI page itself was not clicked.
    2. ✅ The disabled mailbox is listed with enabled: false, its description and its custom quota (100 MB). Its message is still in the mailbox (doveadm mailbox status).
    3. ✅ A master user can log in to the disabled mailbox (qa1*qa3) with IMAP, POP3 and SMTP, while qa1 itself cannot.
    4. ✅ Update from 1.9.3 with a disabled mailbox: it stays disabled, with the description "Migrated from DOVECOT_DISABLED_USERS", and DOVECOT_DISABLED_USERS is removed from the module environment.
    5. ✅ Back up, then restore with "replace": pcdb-init finishes before Postfix and Dovecot start, and the mailbox stays disabled during and after the restore. A login loop for the disabled user never succeeded.
    6. Import from NethServer 7 with a disabled mail service: not tested yet.

    Still to do

    • Clone and move of the Mail application (case 10): needs a second node.
    • Import from NethServer 7 (case 8 above).

    Note: after the restore with "replace", Rspamd of the new instance did not listen on its ports (still held by the replaced instance), and Postfix answered 421 Service unavailable until Rspamd was restarted. It is an old limitation of the restore with "replace", not a regression of 2.0.

  17. DavidePrincipi commented on Nov 27, 2026

    @DavidePrincipi
    MemberAuthor

    QA of clone and move, Mail 2.0.0-beta.6 updated from 1.9.3, on a two-node cluster (Rocky Linux 9.8, core 3.25.1). The source instance had a mailbox disabled during the update (DOVECOT_DISABLED_USERS), a public mailbox with an address, a 1 MB default quota and messages in the public folders.

    Clone to node 2 ✅

    • All containers running, Dovecot 2.4.5, Rspamd listening on its ports.
    • The configuration database is copied with the data: pcdb-init is skipped by its start condition, as designed.
    • Mailbox list: same as the source (disabled user with its description, quotas). Same message counts, vmail without quota limit (2035 KB), users with the 1 MB default.
    • The disabled user cannot log in (IMAP/POP3/SMTP) and RCPT is rejected with 550. The other users log in and receive messages, and the public mailbox address delivers.

    Move to node 2 ✅ (clone with "replace")

    • Same checks as the clone, all passed. The source instance is removed from node 1 and its ports are released; the module UUID is kept.
    • Rspamd started normally: the port conflict seen with the restore with "replace" does not happen here, because the new instance runs on another node.

    Still to do: import from NethServer 7.

  18. DavidePrincipi commented on Nov 27, 2026

    @DavidePrincipi
    MemberAuthor

    VERIFIED

    Import from NethServer 7 (case 8 of the 2.0.0-beta.5 test cases) ✅ NethServer 7.9 Enterprise with local LDAP and the mail server, migrated with nethserver-ns8-migration 1.5.0 to Mail 2.0.0-beta.6 on Rocky Linux 9.8, core 3.25.1. Before the migration: first.user with 5 messages in INBOX (one with an attachment, one with a non-ASCII subject), a folder Archive.2026 with 2 messages, and a forward with a kept copy; second.user with 3 messages and the mail service disabled; an alias info@ with both users as destinations.

    • Dovecot 2.4.5, all containers running.
    • second.user is imported disabled, with the description "Imported from NethServer 7: mail service disabled". Its 3 messages are kept. IMAP, POP3 and SMTP logins fail, and RCPT is rejected with 550 5.1.1 ... User unknown in virtual alias table.
    • root is disabled with the description "Imported from NethServer 7: protects the root mailbox".
    • first.user: same message counts and sizes as on NethServer 7, Archive.2026 keeps its name, full-text search and the non-ASCII subject work. IMAP, POP3 and SMTP logins work.
    • The forward with a kept copy is imported: a new message is stored in the mailbox and forwarded.
    • The alias info@ is imported with both destinations. A message to it reaches first.user, and the copy for the disabled second.user is dropped with no bounce.

    With the previous comments, all the test cases of this issue are checked: update from 1.9.3, logins, delivery and Sieve, quota, folders, full-text search, custom configuration, spam training, master users and disabled mailboxes, Imapsync, WebTop and Roundcube, backup and restore, clone and move, and import from NethServer 7.

  19. added
    verified
    and removed
    testing
    on Nov 27, 2026
  20. moved this from Testing to In Progress in NethServeron Nov 27, 2026
  21. moved this from In Progress to Verified in NethServeron Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

milestone goal 👑verified

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions