Skip to content

Mailu

The Mailu connector needs no Mailu password at all. It reads the domains, users, password hashes, aliases, automatic replies, forwards and DKIM keys from a configuration export made in the admin container. It reads mail and Sieve scripts from Mailu’s internal Dovecot over IMAP and ManageSieve, signing in as each user without a password, which Mailu’s internal network allows. When the Radicale URL and host access are set, it also reads calendars and address books from Mailu’s webdav container. It writes nothing on the source.

Mailu runs on a Docker host the operator controls, so both cutover strategies apply: a zero-downtime migration with the Stalwart proxy in front of Mailu’s front container, or a one-shot migration per domain. Detection recognises Mailu from its API, but only sees the public front, so it never fills the internal IMAP and ManageSieve URLs.

Mail is copied over IMAP with the folder tree, and Sieve scripts over ManageSieve when its URL is set. Each user’s automatic reply is carried as Stalwart’s vacation response, with its start and end dates, and its forward as a redirect rule that keeps a local copy when Mailu does. With Radicale, calendars and address books are copied too. Mailu has no files or sender identities for Vandelay to read.

From the export file:

  • Every domain, with its alternative domains as alias domains.
  • Every user, with its display name and quota. Disabled users and users with IMAP turned off are read as well, and disabled users are created disabled on Stalwart.
  • An alias with one recipient becomes an alias of that account, an alias with several recipients becomes a mailing list, and %@domain with wildcard on becomes the domain’s catch-all address.
  • The DKIM key of each domain, carried when “DKIM keys” imports it, which only a server-scope project does.

Mailu 1.9 and later store passwords as bcrypt-sha256 hashes, which Stalwart cannot verify, so those users receive temporary passwords, and pre-flight lists them. An older hash that Mailu has not rehashed yet is carried, as described in Password hashes.

  1. Export the configuration in the admin container, and keep the file on the Vandelay host:

    Terminal window
    docker compose exec -T admin flask mailu config-export -j -s -f > mailu.json
    chmod 600 mailu.json

    All three options are needed: -j writes JSON, -s includes the password hashes and DKIM keys, and -f writes every field, so that Vandelay can tell a disabled account or a restriction from a default. The file holds secrets, so it stays readable by its owner only. It is a snapshot: when accounts change, it is exported again before the final run.

  2. Find the address of the internal imap container, which the Vandelay host reaches on the mailu_default network or from the Docker host. Only the internal Dovecot accepts a login without a password. The public front refuses it and counts every attempt against AUTH_RATELIMIT_IP and AUTH_RATELIMIT_USER, which can lock real users out, so the IMAP URL must never point at the front.

  3. For calendars and address books, find the IP address of the webdav container on the mailu_radicale network, which docker inspect lists, and make sure the Vandelay host can reach it on port 5232. Radicale has its own Docker network, separate from mailu_default. Then give Vandelay host access to the same Docker host as a user that may run docker: over SSH, or on the Docker host itself with the root directory /. Before any DAV request, Vandelay lists /data/collection-root in the webdav container, because Radicale creates a home for any user it is asked about; a user without a home there has no calendars and gets no loss.

The same steps are printed by vandelay migrate guide mailu and shown on the Source: access step of the web UI and the TUI.

On Mailu, clients do not talk to Dovecot and Postfix directly but to the front container, which authenticates them and forwards their sessions. The settings in Proxy mode settings therefore do not apply as written; Mailu’s own settings in mailu.env replace them:

  • Trusting the proxy. Mailu’s front accepts the real client address from an upstream proxy through the PROXY protocol, not through XCLIENT or the IMAP ID command. The proxy’s destination for Mailu sends a PROXY header (forwarding = "proxy"), REAL_IP_FROM lists the proxy’s address, PROXY_PROTOCOL turns the PROXY protocol on, and REAL_IP_HEADER stays unset, as described in Mailu’s configuration reference for the installed release. Port 25 must not expect the header, because Stalwart relays to it directly, without one.
  • Accepting mail relayed from Stalwart. RELAYNETS lists networks whose mail Mailu relays without authentication. Mailu adds them to Postfix’s mynetworks and to rspamd’s local networks, which skips checks such as SPF for them. Setting it to Stalwart’s address alone keeps the relay right limited to Stalwart.

A change to mailu.env takes effect with docker compose down followed by docker compose up -d; a plain restart does not read it again. Further Postfix, Dovecot and rspamd settings go into the files under the overrides directory, which Mailu’s updates keep.

Vandelay itself reads the internal imap and webdav containers and never goes through the front, so it never passes through the Stalwart proxy either.

The export is “Mailu export file” (source.export, --mailu-export), a path on the Vandelay host. There is no master user; Mailu refuses one in the plan.

The endpoints are the internal containers:

  • “IMAP URL” (source.imap, --imap-url): imap://<imap container address>:143.
  • “ManageSieve URL” (source.sieve, --sieve-url): sieve://<imap container address>:4190, to carry Sieve filters.
  • “Credentials without TLS” (source.cleartext, --cleartext): allow, because the internal services offer no TLS. The plain HTTP Radicale URL needs it too.
  • “DKIM selector” (source.dkim_selector, --dkim-selector, Advanced): Mailu’s DKIM_SELECTOR, when it is not the default dkim.
  • “Radicale URL” (source.radicale, --radicale-url): http://<IP address>:5232/ of the webdav container. A host name such as webdav is refused. When the URL is empty, calendars and contacts are not migrated and pre-flight lists them as a loss. The Radicale URL is part of the source’s identity and cannot change once work is admitted.

Host access and the Radicale URL must point at the same Docker host. Vandelay stops when the listed container does not have the URL’s address, but two Mailu stacks on two hosts can use the same subnets, so a matching address is no proof that it is the same container.

The following excerpt reads the internal containers of a Mailu installation, with Radicale through SSH host access:

[source]
system = "mailu"
imap = "imap://172.20.0.10:143"
sieve = "sieve://172.20.0.10:4190"
export = "/srv/migration/example/mailu.json"
dkim_selector = "dkim"
radicale = "http://172.21.0.5:5232/"
cleartext = "allow"
[source.host]
kind = "ssh"
destination = "[email protected]"

The following command sets the same source:

Terminal window
vandelay migrate source \
--system=mailu \
--mailu-export=/srv/migration/example/mailu.json \
--imap-url=imap://172.20.0.10:143 \
--sieve-url=sieve://172.20.0.10:4190 \
--cleartext=allow \
--radicale-url=http://172.21.0.5:5232/ \
--host-access=ssh \

Pre-flight lists the following as losses:

  • Relayed domains: relayed domain <name> is not migrated; set up its relay on the target.
  • fetchmail jobs and domain managers, which have no counterpart on Stalwart.
  • App passwords (Mailu authentication tokens): clients that sign in with them need new app passwords.
  • Administrator and sending rights: global_admin, and allow_spoofing, which lets a user send as any address.
  • Protocol restrictions. An IMAP or POP3 restriction on a user is not migrated, so the protocol is open to the account on Stalwart: enable_imap is false in Mailu, but the restriction is not migrated; IMAP is open to the account on the target.
  • Wildcard aliases other than the catch-all, and aliases, forwards or addresses that are not valid.
  • Duplicate users in the export, of which the first is kept.
  • DKIM keys that do not parse; the key is exported again with flask mailu config-export -j -s -f.
  • Automatic reply dates that are not dates, in which case the reply is migrated turned off.
  • Calendars and address books when the Radicale URL or host access is missing, when the webdav container has no /data/collection-root, or when a home directory differs from the address only in case, because reading it under the address would create a second, empty principal on the source.

the Radicale URL host <host> is not an address of the webdav container whose collections were listed (it has <addresses>); set radicale to that container's address on the mailu_radicale network means that the Radicale URL names a host name or another container. Set it to the webdav container’s IP address on mailu_radicale. expected one running Mailu webdav (Radicale) container on the source host, found <n> means that host access reaches a Docker host without exactly one running webdav container.

not a Mailu `config-export -j -s -f` file: <error> means that the export was made without one of the three options, or is not a Mailu export. Export it again with all three.

the Radicale URL <url> is plain http; set cleartext = "allow" for a Radicale reached only inside the Docker network is fixed by setting “Credentials without TLS” to allow.