Skip to content

Support Shared IMAP Folders as Shared Inboxes

  • Deciders: Julian Bäume
  • Date: 2026-04-10

Status

Accepted

Context

Teams originally required dedicated shared mail accounts (e.g., support@company.com) where multiple users are granted access to the same App Suite mail account. This works but is rigid — it requires explicit admin configuration of shared accounts, and every team member needs credentials for that account.

Many organizations already use Dovecot shared IMAP folders in two ways:

  1. Public namespaces — admin-configured, server-wide folders (e.g., Public/Support, Public/HR) visible to all users
  2. User-to-user sharing — individual users share their folders via IMAP ACLs (e.g., shared/mschaefer@oxui.de/ad-hoc)

Teams had no way to monitor either type of shared folder.

Decision

Evolve the inbox abstraction so that any IMAP folder — whether a shared account's INBOX or a Dovecot public namespace folder — can be monitored, synced, and collaborated on in Teams.

Key design choices

Discovery via existing MW API: Use folder?action=allVisible&content_type=mail to discover shared folders. Both public namespace folders (type=2) and user-shared folders (type=3) appear in the private array. Namespace root containers are filtered out using ownRights > 0. No new middleware endpoints are needed — Teams acts as a facade, composing existing APIs.

Schema evolution: The inbox table's primary key changes from email (text) to a generic id (text). For shared accounts, id equals the email address. For public folders, id is the folder path (e.g., default0/Public/Support). New columns: folderPath, type (account | publicFolder). The email column becomes nullable (public folders have no email address).

Amended (2026-11-10, MR !1641): Inbox ids of folders that one user shares with others are <contextId>/<path> (e.g. 42/default0/Shared/info/Orders). Such a share never leaves its context, but owners with the same local part in different contexts produce the same canonical path, so a path-only id merged inboxes of different tenants. folderPath keeps the bare path, and each member's local IMAP path stays in users_to_inbox.folder_path. Migration 0019 moves existing user shares; shares whose members already spanned several contexts keep their old id, and the sync of each context's new inbox takes over the threads whose mail it sees. Within one context, owners with the same local part (info@a.example, info@b.example) still share an id: some Dovecot setups show recipients only Shared/<local part>/…, so the domain can't be recovered.

Reply identity: For public folders, replies are sent as the current user's own email address (reply-as-yourself). This requires no Dovecot delegation configuration and is transparent to recipients. Shared accounts continue to send as the shared address.

Unified sidebar: Public folders appear alongside shared accounts in the "Shared Inboxes" sidebar section, with icon guessing based on folder name. Users don't need to distinguish the underlying sharing mechanism.

Consequences

Positive

  • Organizations with Dovecot public namespaces can use Teams without setting up dedicated shared accounts
  • Both public namespaces and user-to-user ACL shares work with the same mechanism
  • No middleware changes required — lower deployment friction

Negative

  • Schema migration required for existing deployments (add id column, rename FK columns)
  • Thread queries use COALESCE(inbox->>'id', inbox->>'email') for backward compatibility with existing thread data
  • Public folder IDs contain slashes, requiring URL encoding in API calls
  • Reply-as-yourself may confuse recipients who expect replies from a team address (configurable reply identity is deferred to a future phase)

Risks

  • Folder path stability: public folder IDs are path-based (not stable across renames). Admin-managed paths are typically stable, but a rename would orphan existing threads.
  • The allVisible API returns public folders in the private array (not a separate public array), which is counterintuitive. The type=2 field is the reliable discriminator.

Alternatives Considered

New MW endpoint: Building a dedicated folder?action=publicFolders endpoint in the Java middleware. Rejected because the existing allVisible API already provides the needed data, and avoiding MW changes reduces deployment complexity.

Separate UI section: Displaying public folders in a separate "Shared Folders" section. Rejected because from the user's perspective, all shared inboxes serve the same purpose regardless of the underlying sharing mechanism.

User-to-user ACL sharing only: Initially considered scoping to public namespaces only, but testing revealed that user-shared folders (type=3) work with the same discovery mechanism. Both types are supported from the start.