Skip to content

Import, export and backup ​

Everything here lives under Settings › General › Import & Export, and each of it has a counterpart in the swanmail command-line tool.

Importing mail ​

Import mail… reads messages from another client:

  • an mbox file — Thunderbird's folders, a Google Takeout export, Apple Mail's .mbox packages (pick the mbox file inside), anything written by a Unix mail tool;
  • a Maildir (a folder with cur/ and new/) or a folder of .eml files, where each file is one message.

Choose the source, the account the mail belongs to, and where it goes:

  • A local folder (the default). The messages are stored on this computer in a folder of that account which no server knows about. It appears in the sidebar with a drive icon, it is searched, threaded and tagged like any other folder, and no sync ever removes it or uploads it. Its messages can be moved between local folders, and deleting one deletes it for good; they cannot be moved into a server folder (import the file again with the server as the destination instead), and for the same reason cannot be archived or marked as junk: Swanmail says so rather than leave them where they are. Local folders can be renamed, deleted and given subfolders from the folder's right-click menu.
  • A mailbox on the server (IMAP, Fastmail/JMAP, Microsoft 365 and Exchange accounts). Each message is uploaded into the mailbox you pick and shows up after the next sync. Microsoft 365 files an uploaded message as a draft, which is how Microsoft Graph stores a message it is handed whole; it also accepts at most about 3 MB per message. A POP3 account can only import into a local folder.

A message whose Message-ID the account already has is skipped, so running the same import twice — or again after cancelling it — adds only what is missing. Read and starred state come from the file where it records them (Status, X-Mozilla-Status, Takeout's Unread and Starred labels, Maildir flags); a message that records nothing is imported as read. The progress line counts what was read, imported, already there, and failed; a message that cannot be stored is counted and the import carries on.

Mail rules do not run on imported messages.

Exporting mail ​

Right-click a folder in the sidebar and choose Export folder… to save it as:

  • an mbox file — every message in one file, which Thunderbird, Apple Mail, mutt and most mail tools can open, and which Swanmail can import again;
  • .eml files — one file per message, named 0001-Subject.eml, 0002-…, in a folder you choose.

Export account… under Import & Export writes every folder of an account as its own mbox file into a folder you choose.

An export is the exact message as the server holds it, attachments and all. Mail in an imported local folder is read from this computer; anything else is downloaded from the server again, so a large folder takes as long as downloading it does. A message that cannot be downloaded (deleted on the server since the last sync, or larger than 100 MB) is counted and left out; the export carries on. The mbox is written in the mboxrd dialect: a From line with the sender and date before each message, and a > added to any line of a message that begins with From (or >From ), which the importer removes again.

Backing up and restoring settings ​

Back up settings… saves a JSON file (swanmail-settings-<date>.json) with what it takes to set Swanmail up again:

  • your preferences — theme, language, reading and notification options, keyboard shortcuts, signatures, templates, smart mailboxes, VIP senders and the per-sender remote-image exceptions;
  • each account as it would be added again — address, name, protocol, servers and ports, send-as aliases, colour, folder labels and its AI agent;
  • AI agent configurations, rules, blocked senders and tags.

It holds no passwords, sign-in tokens or AI API keys, nor an agent's environment variables, so it is safe to keep with your other files. The order of your top-level folders is not included: it refers to folders by a number that only this computer knows.

Restore settings… opens a backup and shows what it holds and what restoring it would change before anything happens. Choose how:

  • Merge (the default) adds what is missing and updates what matches — an account by address, a rule, tag or agent by name — and keeps everything else. Templates, signatures and VIP senders are combined rather than replaced.
  • Replace makes your rules, tags, blocked senders and agents exactly the backup's and takes its preferences as they are. It never removes an account or any mail.

An account the backup adds arrives without its password or sign-in, marked in the sidebar like an account whose sign-in has expired: choose Re-authenticate to enter the password (or sign in with the provider) and it starts syncing. An agent restored from a backup needs its API key entered again. A folder label or a rule that files mail into a folder waits for that folder to exist, so restore again after the account's first sync to bring those back too.