Rules

Rules

Import from MailManager

Import your MailManager rules into Postern with postern-hub import-mailmanager, for Docker, systemd and the desktop app's built-in Hub, and what is and is not carried over.

This page has instructions for several ways of running the Hub. Each is shown under its name.

If you used MailManager, the Hub can take over its rules. This page explains what the import does, how to run it for your install method, how to read its report, and how to switch over without sending anything twice.

What the import does #

postern-hub import-mailmanager reads MailManager's database file and creates Postern rules from its rules. MailManager's database is opened read-only and never changed.

  • Mailboxes are matched by address. Each MailManager mailbox is matched to the Postern mailbox with the same email address, for the Postern user you import for. Add your mailboxes to Postern before you import. Rules of mailboxes that Postern does not have are skipped.
  • Every imported rule is in Test mode, also rules that were live in MailManager. Those get the note "Live in MailManager; imported in Test mode". Whether a rule is turned on or off is kept.
  • Running it again is safe. Each imported rule gets an ID derived from the MailManager rule, so a second run reports the rules it imported before as "Already imported earlier (left as they are)" and does not touch them, even if you changed them in Postern. Only new rules are added.
  • Conditions, exceptions and the match setting carry over. Rules are imported in MailManager's order. A rule without conditions gets "Header From exists", which matches every message, with a note in the report.
  • A MailManager rule for all accounts that moves or copies to a folder becomes one Postern rule per mailbox, because a folder belongs to one mailbox. Mailboxes without that folder are noted as "Not for ...".

How actions are mapped #

MailManager action Postern step
Redirect, Forward, Reply Redirect, Forward, Reply automatically
Capture, Delete Capture, Delete
Mark as read, Mark as unread Mark as read, Mark as unread
Flag, Unflag Star, Remove star
Notify Send a notification with Also send it to your alert channels ticked
Webhook Call a web address
Move Move to folder
Copy Copy to folder

The folder of a move or copy is looked up in the Postern mailbox by its ID at the provider, its path, the path with . read as / (ignoring case), or its bare name.

What is skipped #

Reason in the report What to do
it runs a script; Postern does not run scripts (use a webhook instead) Rebuild it with Call a web address and a small receiver. See Webhooks.
no Postern mailbox with this address Add the mailbox in Postern and run the import again.
folder "Clients/Acme" is not in the mailbox Create the folder at your provider, wait for Postern to sync it, and run the import again.
Postern can't use it as it is: ... Usually a pattern that Postern's pattern syntax does not support, such as a look-ahead. Recreate the rule by hand. See Patterns.
an unknown action, a deleted account, or a definition that cannot be read Recreate the rule by hand.

What is not imported #

The report ends with this list:

  • Captured mail. MailManager encrypts it with its own key. Download what you need in MailManager first.
  • Alert channels. Set them up again in Settings → Notifications. See Alerts.
  • The activity log and MailManager's users.

Before you start #

  • Postern has the user you import for, and that user has added all mailboxes whose rules you want.
  • Stop MailManager, or at least its rule processing, so its database file is complete and unchanged while you copy it. Copy the database file (here called mailmanager.db) to the machine that runs the Hub.
  • The Hub must be stopped during the import. A running Hub holds its data directory, and the import refuses with "the data directory is in use by a running Hub: stop the Hub, run the import, then start the Hub again".
  • If the Hub has several users, you need --user you@example.com. With one user it is chosen automatically.

The command:

postern-hub import-mailmanager <mailmanager.db> [--user <email>] [--dry-run]

--dry-run only reports what would be imported and changes nothing. Always run it first.

Run the import #

Docker Compose

The container cannot see files on the host, so copy the database into the data volume, run the import in a one-off container while the Hub is stopped, then remove the copy.

  1. Stop the Hub and copy the file into the volume. docker compose cp makes the copy owned by root, so make it readable first:

    cd ~/postern
    docker compose stop hub
    chmod 644 mailmanager.db
    docker compose cp mailmanager.db hub:/data/mailmanager.db
  2. Run a dry run and read the report:

    docker compose run --rm hub import-mailmanager /data/mailmanager.db --dry-run

    Add --user you@example.com if the Hub has several users.

  3. Run the import:

    docker compose run --rm hub import-mailmanager /data/mailmanager.db
  4. Remove the copy and start the Hub:

    docker compose run --rm --entrypoint rm hub /data/mailmanager.db
    docker compose start hub

Check: the report ends with a line like "12 imported, 0 already there, 2 skipped.", and Settings → Rules lists the imported rules with the Test label.

If it did not work: "does not look like a MailManager database (no rules and accounts tables)" means the file is not MailManager's database, or the copy is incomplete. "the data directory is in use by a running Hub" means the Hub still runs: check with docker compose ps. If docker compose cp fails because the container does not exist, start the Hub once with docker compose up -d, then begin again at step 1.

Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS

The Hub runs as the postern user, which must be able to read the file.

  1. Stop the Hub and put the file where the postern user can read it:

    sudo systemctl stop postern-hub
    sudo install -o postern -g postern -m 0600 mailmanager.db /var/lib/postern/mailmanager.db
  2. Run a dry run and read the report:

    sudo -u postern sh -c 'set -a; . /etc/postern/hub.env; exec postern-hub import-mailmanager /var/lib/postern/mailmanager.db --dry-run'

    Add --user you@example.com before the closing quote if the Hub has several users.

  3. Run the import:

    sudo -u postern sh -c 'set -a; . /etc/postern/hub.env; exec postern-hub import-mailmanager /var/lib/postern/mailmanager.db'
  4. Remove the copy and start the Hub:

    sudo rm /var/lib/postern/mailmanager.db
    sudo systemctl start postern-hub

Check: the report ends with a line like "12 imported, 0 already there, 2 skipped.", and Settings → Rules lists the imported rules with the Test label.

If it did not work: "does not look like a MailManager database (no rules and accounts tables)" means the file is not MailManager's database. "the data directory is in use by a running Hub" means the Hub still runs: check with systemctl status postern-hub. A "permission denied" means the postern user cannot read the file: repeat step 1.

Desktop app (built-in Hub)

The desktop app has no menu item for the import, but you can run the built-in Hub's program from a terminal while the app is closed. This only works if your build of the app contains the built-in Hub.

  1. Quit the app completely. Quitting stops the built-in Hub.

  2. On macOS, run a dry run (the paths below are the default install and data locations):

    "/Applications/Postern.app/Contents/Resources/hub/hub" import-mailmanager \
      --data-dir "$HOME/Library/Application Support/Postern/hub-data" \
      --key-file "$HOME/Library/Application Support/Postern/hub-key/hub.key" \
      ~/mailmanager.db --dry-run
  3. Run the same command without --dry-run.

  4. Start the app again.

On Windows and Linux the program is hub.exe or hub in the resources/hub folder of the installed app. Use the data folder %APPDATA%\Postern or ~/.config/Postern in place of the macOS one, with hub-data and hub-key/hub.key inside it.

Check: the report ends with a line like "12 imported, 0 already there, 2 skipped.", and Settings → Rules in the app lists the imported rules with the Test label.

If it did not work: "the data directory is in use by a running Hub" means the app is still running: quit it fully. If the program file does not exist, your build has no built-in Hub; run the import on a Hub installed with one of the other methods.

Read the report #

A dry run prints something like this:

Importing MailManager rules from /data/mailmanager.db for you@example.com
Dry run: nothing was changed.

Mailboxes:
  you@example.com → Postern mailbox mbx_01jf7a2b3c4d5e6f7g8h9j0k1m
  old@example.org → no Postern mailbox with this address (its rules are skipped)

Would be imported (in Test mode):
  + "Invoices to accounting" [you@example.com] → rul_01jf8k2m3n4p5q6r7s8t9v0w1x
      Live in MailManager; imported in Test mode
  + "Newsletters" [you@example.com] → rul_01jf8k2m3n4p5q6r7s8t9v0w2y

Skipped:
  - "Run backup script" [you@example.com]: it runs a script; Postern does not run scripts (use a webhook instead)

Not imported: captured mail (MailManager encrypts it with its own key; download it there first if you need it),
alert channels (set them up in Settings → Notifications), the activity log and MailManager users.

2 would be imported, 0 already there, 1 skipped.
The rules are in Test mode: they only record what they would do (Settings → Rules → Activity).
Compare with MailManager for a few days, then switch them to Live and stop MailManager's rules.
Never let both enforce the same redirect.

+ lines are rules that are (or would be) created, with notes below them. - lines are skipped rules with the reason. The activity log the report mentions is under Settings → Rule activity.

Error Meaning
no Postern user you@example.com --user names an address that has no Postern account on this Hub.
this Hub has no users yet Create your account first.
this Hub has several users (...): choose one with --user Add --user with one of the listed addresses.
--user needs an email address --user was the last argument.

Switch over #

  1. Leave MailManager running and the imported rules in Test mode for a few days.
  2. Compare Settings → Rule activity in Postern with MailManager's log. Every message MailManager acted on should have a Simulated entry in Postern with the same steps.
  3. When they agree, for each rule: switch it to Live in Postern and turn it off in MailManager at the same time.

Warning

Never let a rule be live in both MailManager and Postern. Both would redirect, forward or reply, and the recipient would get every message twice. A redirect in both could also delete the message before the other one has kept its copy.

See Test mode for what to check before switching a rule to Live.