Skip to content

Other IMAP servers

The IMAP source migrates from any server that speaks IMAP: Cyrus, Courier, a Dovecot whose user database Vandelay cannot read, an LDAP-based installation of a system that has its own connector, or a hosted provider that offers IMAP. It reads mail over IMAP and, when the server offers ManageSieve, the Sieve scripts. It cannot list the accounts itself, so they come from an accounts CSV, or, in a single-account project, from that account’s own sign-in.

The source carries less than a dedicated connector. Calendars, contacts, files, DKIM keys, mailing lists, group members and password hashes are not read, and the kind of each account, its aliases, display name and quota come only from the CSV. Where a connector exists for the system, it is the better choice; this source is the fallback for everything else. Both cutover strategies apply. A zero-downtime migration needs a server that the Stalwart proxy can front and that accepts mail relayed from Stalwart; a one-shot migration works with any server, hosted or not.

Mail is copied folder by folder from the personal namespace, with flags and keywords; messages marked as deleted are skipped. Sieve scripts are copied over ManageSieve, with the active script kept active, when “ManageSieve URL” is set. Vacation responses and filters that the server keeps in Sieve come along with the scripts; settings kept anywhere else do not.

Each CSV row becomes one account on Stalwart, of the kind its kind column names: a user, a shared mailbox, a group, a room or an equipment resource. The domains are taken from the addresses and aliases in the file. The row’s aliases, display_name and quota columns are applied as given, and target gives the account a different address on Stalwart.

No password hash is read, so the password mode “Keep existing passwords where possible” gives every account a temporary password. The single-account form is the exception: the account’s own password, read from its reference, is handed to provisioning as a clear-text password, so it is carried to Stalwart when “Carry clear-text passwords” is on.

Prepare the source in three steps:

  1. Choose how Vandelay signs in to each account. A master user reads every mailbox without the users’ passwords, and suits servers that support one, such as Dovecot, Cyrus and Zimbra. Per-account passwords suit servers without a master user, including hosted providers; where the provider requires app passwords, the references point at those. The single-account form suits a project that moves one account with its own credentials. The master user section describes the login forms.
  2. Write the accounts CSV, with one row per account and, for per-account passwords, a password column of secret references. Keep it in the project directory, so that relative file: references resolve next to it.
  3. Check that IMAP and ManageSieve are reachable from the Vandelay host, with TLS. A server with a self-signed certificate needs a certificate pin.

The following CSV lists three accounts: a user with an alias, a user whose login differs from the address, and a shared mailbox moved to a new address:

address,target,kind,login,password,aliases
[email protected],,user,,env:ALICE_PASSWORD,[email protected]
[email protected],,user,bob,file:secrets/bob.txt,
[email protected],[email protected],shared,,file:secrets/info.txt,

The connection is set by “IMAP URL” (source.imap), imaps://host for implicit TLS on port 993 or imap://host for STARTTLS on port 143, and by “ManageSieve URL” (source.sieve), sieves://host or sieve://host, left empty when the server has no ManageSieve. A port other than the default is added after the host.

The accounts come from exactly one place. “Accounts CSV” (source.accounts) names the CSV. In a single-account project, “Account address” (source.user.address), “Account password” (source.user.password) and, when the login differs from the address, “Account login” (source.user.login) replace the CSV; this form cannot be combined with a CSV or a master user. “Master user” (source.master.name) and its password (source.master.password) are optional with a CSV: with them, the CSV needs no passwords.

The following command sets an IMAP source with a master user and an accounts CSV:

Terminal window
vandelay migrate source --system=imap \
--imap-url=imaps://mail-old.example.org \
--sieve-url=sieve://mail-old.example.org \
--accounts=accounts.csv \
--master-user=vandelay \
--master-password=env:VANDELAY_MASTER

The same settings in plan.toml:

[source]
system = "imap"
imap = "imaps://mail-old.example.org"
sieve = "sieve://mail-old.example.org"
accounts = "accounts.csv"
master = { name = "vandelay", password = "env:VANDELAY_MASTER" }

The connection test signs in to one account from the CSV and lists its folders. A login that succeeds but lists no folders usually means that the master user cannot see the user’s mailbox; on Dovecot, the Dovecot and Postfix page shows the ACL setting that fixes this.

The IMAP source reports no losses of its own, because it knows nothing beyond what IMAP and ManageSieve show. Everything else the server holds, such as calendars, contacts, server-side forwarding, shared folder permissions and settings stored outside Sieve, is left behind without a report. Review the server for such data before the migration, and move calendars and contacts with the per-account CalDAV and CardDAV importers where the server offers them.