The Mail-Sync Policy

An instance may declare that the people of certain identity domains keep their mail, calendar and Teams off it. Such a person connects no Microsoft 365, Teams, Google, IMAP/SMTP, CalDAV or iCloud account there, and nothing reads an account they connected before. They are told where it belongs instead: their company instance or their own local instance. Policy mail-sync-blocked-domains (core Doc/Architecture/PolicyNotProse → the register).

The typical use is the public instance of an operator whose own staff sign in there too: the operator's work mail belongs on the company instance or on each person's own machine, not on the shared public one.

The declaration

The policy is declared configuration on the deployment record — never a domain written into code (policy declared-not-derived):

Key Form Meaning
MailSync:BlockedDomains an array (MailSync__BlockedDomains__0=example.com) or one comma-separated value the domains whose people are refused; a sub-domain (mail.example.com) falls under its domain, a look-alike (notexample.com) does not
MailSync:Message optional text, {0} is the matched domain replaces the default sentence a refused person reads

Absent or empty means no restriction, and that is the default everywhere. A company instance and a person's own local instance declare nothing and are unaffected; only the instance that wants the restriction sets the key, in its record's extraPortalConfig.

Who is blocked

A person is blocked when any of their identities is in a declared domain:

On the iCloud calendar the set is narrower: an in-mesh node source cannot reach the portal's user directory, so it matches the session's sign-in address and the Apple ID. The sign-in address IS the directory email for every person the portal resolves (the session's user is found by that email), so this misses only a person whose directory email and sign-in address differ.

So a person who signs in with a private address but connects a mailbox in a blocked domain is refused too, and a person whose directory email is in a blocked domain is refused whatever mailbox they connect.

Where it is enforced

Step What happens to a blocked person Where
/auth/ea/connect (Microsoft 365 and Teams consent) 403 with the policy sentence, before Microsoft is asked anything EaConsentController (portal host)
/auth/ea/callback 403; a consent that began before the policy was declared stores nothing EaConsentController
the delegated token mint no token; the stored grant is kept, never redeemed EaGraphAuth (portal host) and MailSyncGatedEaGraphAuth (Mail module)
/api/google/connect/start 403 with the policy sentence Gmail module, BrokerEndpoints
the Google credential read no credential: no live Gmail read, no copy, no triage MeshGmailCredentialSource
Connect / Add account / Reconnect on the Microsoft 365 and Teams connections Unavailable, with the policy sentence as the reason Microsoft365ConnectionProvider, TeamsConnectionProvider
Connect on Other email (IMAP/SMTP) and Other calendar (CalDAV) Unavailable, with the policy sentence, so the credential form is not offered from any surface. These two channels store and test a sign-in only — no reader in the platform reads them in the background or live, so there is nothing further to stop OtherEmailConnectionProvider, OtherCalendarConnectionProvider
the Add account step /{user}/MailAccounts/Add the policy instead of the provider tiles Gmail module, AddMailAccount
the Mail accounts view /{user}/MailAccounts the policy instead of the account rows and Connect buttons MailAccountsArea.PolicyPage
the inbox's accounts bar no "connect" notes, only the button to the accounts view MailAccountsArea.RenderInboxBar
the mail copy (MailCopyKeeper) never kicked; logged as a skip MailCopyKeeper
inbox triage, the reply drafter, the calendar suggester, triage on an inbox visit the person's "wanted" answers no without reading the preference; logged as a skip MailSyncPolicy.Gate
Teams chat ingestion and the assistant's mailbox, calendar and Teams tools no token, and the tools answer with the policy sentence rather than a consent link MailSyncGatedEaGraphAuth
the iCloud calendar (ICloud/Calendar) the policy instead of the credentials form or the agenda; iCloud is not read IcMailSyncPolicy (node source)

A skip is logged as Mail sync policy: {Reader} skipped {Owner} — …, at most once every 30 minutes per reader and person. The host logs EA connect: refused for {User} by the mail-sync policy at a refused connect.

🚨 One key, three readers. The rule is MailSyncRules in the Mail module (src/MeshWeaver.Mail.MicrosoftGraph/Policy). The portal host (EaMailSyncPolicy) cannot reference a registry-served module, and the iCloud node source (IcMailSyncPolicy) compiles against the in-mesh reference set, which carries no compiled module — so each holds its own short copy of the match, pinned by the same test cases. The host's copy is NOT a linked source file on purpose: a linked file makes the project graph count the host as compiling the Mail package, which widens the suites every Mail, AI and Essentials pull request owes by the whole host closure.

What it never does

It deletes nothing. Grants (Auth/EaUsers/{user}), copies ({user}/_Mailbox/…), triage verdicts, prepared replies, Google account nodes and iCloud connections all stay exactly as they are. The policy stops what would read or write them; what happens to existing data is a separate decision for the instance's owner. Taking a domain off the list resumes everything without a reconnect.

It does not stop mail the platform itself sends (invitations, notifications) and does not touch the shared inbox's inbound intake.

How a change reaches the running portal

The keys are read when the process starts (the policy is built once per process, like every other module option), so a change needs the portal pods to restart. That happens by itself: the record's extraPortalConfig renders into the portal ConfigMap, the portal Deployment carries a checksum/config annotation over it, and the control plane's record-change Reconcile applies the new render — which rolls the pods. No hand roll, and nothing to recycle per node.

Tests