Skip to main content

Workspace mailboxes — configuration

For whoever looks after the workspace and, where it is ours to run, the installation. What switches mail on and off, who may do what, the settings, what the operator registers with Google and Microsoft and runs (the mail worker), how mail is read, and what happens when somebody leaves or has their password reset.

The switch​

Mail (workspace.mail) is a workspace app, on by default in every workspace whose account holds it, sold on its own. Switching it off refuses everything mail — no mailbox is listed, connected, checked or changed, and the hourly and nightly jobs skip the workspace — and deletes nothing: the mailboxes, their members and their connections stay, and switching it on again finds them as they were.

Permissions​

PermissionWho holds itWhat it allows
mailbox.readEvery seeded roleSee the shared mailboxes you are in, and your own
mailbox.connectEvery seeded roleConnect your own mailbox; connect, reconnect, rename or disconnect a shared mailbox you manage
mailbox.manageAdmin only (no seeded role is granted it)Make shared mailboxes; manage any of them — members, managers, connecting; choose the workspace's own Google or Microsoft application
mail.sendManager, Sales, Warehouse, Accounting (not ReadOnly)Write and send mail from a mailbox you are in — a shared mailbox's member or manager, or your own. Holding it never reaches a mailbox you are not in: mailbox.manage alone, an Admin's included, sends from nothing. Refused to a support session and to the assistant

No permission reaches somebody's own mailbox. An Admin holds every permission and is still refused it; so is a support session. mailbox.connect and mailbox.manage are both refused to a support session, because a connection or a membership outlives the session.

A shared mailbox's managers add and remove members and managers and connect it, without mailbox.manage.

The settings​

SettingDefaultWhat it does
workspace.mail_keep_days30How many days a personal mailbox's mail is kept after it is disconnected, or after its owner leaves, so they can ask for a copy; then it is removed
workspace.mail_backfill_days30How many days back a newly connected mailbox is read, and how far back it is read again when Google or Microsoft can no longer say what changed (1 to 365)
workspace.mail_retention_days0 (off)How many days synced mail is kept in the workspace; older mail has its words and files removed here, one at a time, each night. Off keeps it while the mailbox is connected. The mail itself stays with Google or Microsoft either way
workspace.mail_attachment_max_mb25The largest file kept from a message (1 to 100). A larger one stays with the provider, and the message says a file was left there. The original message as received is then not kept either (it holds that file): its text and its smaller files are, and the whole message is still at the provider
workspace.mail_sends_per_hour200How many messages one mailbox may send in an hour (1 to 5,000). Past it a send is refused until the hour is up, with how long to wait; what was written stays a draft. Counted on the server, per mailbox, whoever sends. A message scheduled with Send later is counted in the hour it goes; over the limit then, it waits for the next hour
workspace.mail_undo_seconds10How many seconds a sent message waits before it goes, so its sender can choose Undo (0 to 60). 0 sends at once
workspace.mail_file_on_recordsAddresses and domainsWhether mail threads are linked to the customers and suppliers they are with (Filing by address below): Addresses and domains, Addresses only, or Off
workspace.mail_filing_ignore(empty)Addresses and domains never filed on a record, one per line or separated by commas: an accountant you share, a partner's domain. @example.com and example.com are both a domain. Up to 500

A shared mailbox is never removed by this: disconnected, its mail and team state stay, read-only.

What the operator registers (Google and Microsoft)​

The workspace connects mailboxes through an OAuth application. By default it is the installation's own, configured in the deployment's environment — a second pair, separate from the send-only pair company mail uses (GOOGLE_OAUTH_*, MICROSOFT_OAUTH_*), because mailboxes need wider scopes and Google's gmail.modify is a restricted scope with its own verification:

Environment variableWhat
MAILBOX_GOOGLE_CLIENT_ID, MAILBOX_GOOGLE_CLIENT_SECRETA Google Cloud OAuth client of type Web application
MAILBOX_MICROSOFT_CLIENT_ID, MAILBOX_MICROSOFT_CLIENT_SECRETA Microsoft Entra app registration, multitenant, with a client secret

Each needs:

  • Redirect URI: https://<your host>/oauth/callback (the same page the send-only connection uses; register it on the new application too).
  • Google scopes (frozen): https://www.googleapis.com/auth/gmail.modify, https://www.googleapis.com/auth/calendar.events, openid, email. The Gmail API and the Google Calendar API enabled on the project.
  • Microsoft delegated permissions (frozen): Mail.ReadWrite, Mail.Send, Mail.ReadWrite.Shared, Mail.Send.Shared, Calendars.ReadWrite, offline_access, User.Read. Not Mail.Read as an application permission: it would reach every mailbox in a customer's tenant.

The calendar scopes are asked for now so that calendar sync, later, asks nobody to consent twice.

Until Google has verified the application (and its yearly security assessment), an application offered to outside customers cannot be used for gmail.modify. Until then a Google Workspace customer brings their own OAuth client marked Internal (it connects only their own organisation's mailboxes); a client left in Testing is not offered, because its refresh tokens last seven days. A Microsoft customer may use their own app registration in their tenant.

Putting the installation's Google application in place​

Once the installation's Google application is registered, every company on the installation connects Gmail and Google Workspace mailboxes with one click, with nothing to enter:

  1. Add MAILBOX_GOOGLE_CLIENT_ID and MAILBOX_GOOGLE_CLIENT_SECRET as two keys of the environment's application secret, beside the keys already there.
  2. Switch the Google mailbox connection on for the installation. The API and the worker are given both keys; a server told to read a key the secret does not hold does not start, so the keys go in first.
  3. Open Your mailboxes and choose Connect with Google: the message that the installation has no application registered is gone.

If the application's consent screen is Internal, only accounts of the Google Workspace organisation it was made in can connect through it; another company's Google mailboxes need the application to be External and verified by Google, or that company's own application (below).

The workspace's own application​

Whoever holds mailbox.manage enters the workspace's own application on Shared mailboxes, Your own Google or Microsoft application: its client ID and secret, both or neither. They go to the vault and win over the installation's; the secret is never shown again. A mailbox already connected keeps the application it was connected through until it is reconnected. A Microsoft application of your own must be multitenant (the sign-in page used is Microsoft's common one).

Tokens​

A mailbox's refresh token is kept in the vault, one per mailbox, and nowhere else; it is never shown, logged or sent to the browser. Microsoft issues a new refresh token when one is used, and the workspace keeps the newest.

When somebody's password is reset (the lock)​

When somebody other than the person sets their password (including a temporary, handed-over one), resets their second sign-in step, or changes the address they sign in with, that person's own mailboxes are locked. A locked mailbox is not read, shown or used — not to an administrator, not to the person — until the person signs in to the mail provider again from Your mailboxes, to the same mailbox and the same account at Google or Microsoft. An administrator who reset somebody's password and second factor and signed in as them therefore reaches none of their mail. A person changing their own password does not lock anything.

Opening a password link somebody else was shown counts as a reset too: when you send a person a reset link and the screen shows it to you (or the operator's command line prints it), and the link is used on a login that already had a password, that person's mailboxes lock. A link only emailed to them does not.

While the password in use is one somebody else set — an administrator set it, a login was made with a typed password, or the person still has to change it — the person cannot connect or reconnect a mailbox of their own at all: they are asked to change their password from their profile first. This covers a password set before the mailbox was connected.

Mailbox permissions are never on the credentials screen: an administrator does not see, replace or remove a person's mailbox connection there, and the usage report counts mailboxes together, not one by one.

When somebody leaves​

When a sign-in is closed (or the person no longer holds a role in the workspace), the hourly job, within the hour — whether mail is switched on or off:

  • stops each of their own mailboxes and gives its permission back to Google (Microsoft has no way to take one permission back: it is forgotten). Google takes back the whole permission the application held for that account: if the same Google account was also connected in another workspace on this installation's application, that one asks to be reconnected too; the mail is kept for workspace.mail_keep_days, then removed by the nightly job;
  • stops each shared mailbox connected through their sign-in, as Needs reconnecting, naming them, for a manager with access to reconnect;
  • ends their place in every shared mailbox.

Open conversations given to them are listed under Somebody who has left, with their open tasks.

How mail is read​

Every connected mailbox is read by the mail worker (worker-mail), a service of its own on its own queue (mail), so reading mail never waits behind the company's jobs and never holds them up. A shared mailbox is read about every minute while mail is arriving, and every fifteen minutes once it has had nothing new for an hour. Where the installation has set up push (below), Google and Microsoft also tell us as soon as something arrives and the mailbox is read at once; the regular reading stays as the safety net.

  • What is read. Gmail: the whole mailbox but Spam, Trash and drafts. Microsoft: the Inbox, the folders directly under it (where a rule files mail), Sent Items and Archive; never Junk Email, Deleted Items, Drafts or the Outbox. Labels, folders and categories are not copied into the workspace, and nothing is written back to the provider.
  • First read. A newly connected mailbox reads the last workspace.mail_backfill_days days; its screen says Reading its recent mail for the first time until that is done.
  • Each message once. However often a mailbox is read, each message arrives once. Two messages the companies sent about the same record are two messages, and a copy of one that reaches a workspace mailbox is shown as sent, never as a customer's reply.
  • One bad message never stops a mailbox. A message that cannot be kept (malformed beyond reading, or refused by the database) is skipped and the rest of the mailbox is read; a message deleted at the provider before it was read is skipped too. Neither is retried, and neither counts as a problem with the mailbox.
  • Pictures from the internet are not loaded when a message is opened: a picture inside the message shows, one fetched from a sender's server waits until the reader asks for it (a remote picture tells the sender when and where a message was read).
  • Files from mail are not scanned (there is no virus scanner in this release). They are kept by mail's own path — the upload limit and the upload extension list do not apply, workspace.mail_attachment_max_mb does — and are only ever downloaded, never opened in the page. Calendar invitations (.ics) are kept for the calendar (a later release).
  • Personal mailboxes are not indexed for the assistant (Q5): only shared mailboxes will be, when the assistant learns to read mail.
  • A problem is shown on the mailbox's own screen with when it will be tried again. When Google or Microsoft refuses the connection, the mailbox says Needs reconnecting and its owner (or a shared mailbox's managers) get a notice; nothing is tried against it until somebody reconnects it.

Working mail: who may do what (H3c)​

The Mail screen needs conversation.read and mailbox.read; every act on a conversation needs conversation.write (every seeded role but ReadOnly) and that the person may see it — a shared mailbox's members, or whoever holds mailbox.manage; a personal mailbox's owner alone. No new permission and no new Setting.

  • Assign: only to a member of the conversation's mailbox (the menu offers only them). A personal mailbox's conversation is given to nobody.
  • Notes: a member may write one; @ names only the mailbox's people, and only they are told. A personal mailbox's conversation takes no note. (The brief's Q7 — the owner sharing one personal conversation — is not built; this is its stated default.)
  • Close and reopen: anyone who may write. A customer's reply reopens a closed conversation by itself (a person's mail, received after it was closed; never mail a machine sent, nor your own, nor a spam one).
  • Snooze: each person's own.
  • Spam: closes it and marks it; it leaves the lists, a reply does not reopen it, and it counts in no reply target or measure. Not spam takes the mark off and leaves it closed. Both are in the audit log with who.
  • Move to another mailbox: only between shared mailboxes the person may see; never into or out of a personal one, never in a support session. Who has it goes with it unless they are not in the new mailbox (then it is unassigned). Replies keep arriving through the first mailbox's address and land in the conversation, in its new mailbox. Audited with the two mailboxes.
  • Merge and move a message to a new conversation stay inside one mailbox.
  • The sender match. When an inbound sender's address is a workspace contact's, the conversation offers to link the contact. It is an offer; nothing is linked until a person chooses to (mail is filed onto a record by the signed reference only, below).

Safety. A message's formatted version is cleaned on the way in and again when shown, served with a policy that lets nothing run and fetches nothing, and shown in a frame with no scripts and no access to the page. Pictures from the internet stay blocked until the reader asks, per message. The original message and every file only download, with the browser told never to guess their type.

Sending mail (H3d)​

From where. A person sends from a mailbox they are in, with its address: a shared mailbox's member or manager, or their own personal mailbox. Nobody sends from a personal mailbox but its owner (an Admin, a support session and the assistant included), and a personal mailbox locked by a credential reset sends nothing until its owner reconnects it — a message scheduled before the reset fails instead of going.

Send As. Google sends only as the account's own address or a verified Send mail as alias; the workspace reads the account's alias list before each send and refuses otherwise. A Microsoft shared mailbox needs Send As (or Send on Behalf) granted in Exchange to the member whose sign-in carries it, besides the Full Access reading needs: without it Microsoft refuses the send, and the message says so in those words. The mailbox stays connected.

Once. Every message is sent once under its own id. A send that stops part way (a worker restarted, the provider did not answer) is marked Not sent — may or may not have gone, its sender told, and never sent again by itself; when the mailbox's next read finds the copy in Sent, it is marked sent.

Large files. Up to 25 MB of files a message. Over the size Google or Microsoft take in one piece (about 5 MB and 3 MB), the message goes by Google's upload endpoint or a Microsoft upload session.

Co-drafting. One person writes a conversation's reply at a time; the others see who, and may take it over (the conversation records it). A lock lasts two minutes after its holder's screen last said it was open.

Audit. Queued, cancelled, sent, failed, retried, discarded and taken over are audited with ids, counts and reasons — never an address, a subject or a word of the message.

Replies filed onto records​

Mail the companies send about a record — an invoice, a quote, a purchase order, a dunning reminder, a collections letter, a payment link — carries a signed reference to that record. When the customer's reply arrives in a workspace mailbox, the record's timeline gets one line: a reply arrived in a workspace mailbox. The line says nothing the customer wrote, and is shown only to the people who may read that mailbox. A reply is filed only by that reference, never by matching the sender's address (filing by address, below, links the thread instead), and only onto a company of this account. Automatic mail (out-of-office, mailing lists, bulk mail) is never filed, and at most five replies an hour are filed from one thread and twenty onto one record, so two machines answering each other cannot fill a timeline. Who sees the line is worked out each time the record is opened: somebody added to the mailbox later sees it, somebody removed no longer does, and nobody sees it while mail is switched off.

Filing by address​

A mail thread is linked to the customer or supplier it is with, so the record's people can find it, the way a person links one by hand (Link a record). As each message is read, its sender and the people on To and Cc are looked up:

  • An address a record holds — a customer's or supplier's own email, a customer's addresses by purpose (billing, statements), the email of one of its contacts. An address two records of one company hold links neither.
  • A domain exactly one record holds (workspace.mail_file_on_records set to Addresses and domains), for a company where no address matched: the domain of its website or of an address it holds. Free mail (gmail.com, outlook.com, yahoo.com and the like) is never matched by domain.

Never filed: automatic mail and machine addresses (no-reply@, bounces); the account's own people, their domains and every mailbox's own domain; what workspace.mail_filing_ignore lists; a company of another account. A link somebody takes off is never made again on that thread. At most five links are made on one thread.

Which mailboxes. A shared mailbox files by default; its managers can turn it off on its page (File on customers and suppliers). A personal mailbox never files unless its owner turns it on there.

Who sees what does not change. The mail stays visible only to the mailbox's people. The record shows a line saying a conversation was linked, and that line is shown only to people who may see the thread. Somebody who may read the customer but not the mailbox sees nothing new, unless the mailbox chooses otherwise (below).

Shown on customers and suppliers. Each mailbox chooses what people outside it see of its threads on a customer's or supplier's Mail tab, when they may read that customer or supplier:

ChoiceThey see
Only to this mailbox (the default)Nothing
Who and whenThat there is a thread: who wrote last, how many messages, when, and which mailbox it is in
Who, when and the subjectThat, and its subject

They never read the mail, its notes or its files, and the thread does not open for them: to see more, they ask one of the mailbox's people. A shared mailbox's managers choose on its page; a personal mailbox's is its owner's alone. A support session sees none of it.

How quickly. The addresses are read from each company once an hour (what changed since the last read) and in full once a day. A customer added or a contact's address changed is matched from the next hourly read; a contact removed outright drops out at the next full read. Mail already read is not filed again when an address is added later; it is filed from its next message.

The switch on a mailbox is audited (mailboxes.file_on_records). The links are made by the system and their lines say so ("Filed on a customer or supplier by the mail's addresses").

Push: new mail read as it arrives (H3e)​

Without push a mailbox is read every minute while busy and every fifteen minutes once quiet. With push, Google or Microsoft tells the installation that something changed and the mailbox is read at once. The regular reading continues underneath, so a notice that is late or lost costs at most fifteen minutes. Each mailbox's screen says, in one line under New mail, whether its mail is pushed, and if not, why.

Which mailboxes get push.

MailboxPush
Gmail or Google Workspace, connected through the installation's own Google applicationYes, once the installation has set up Google push
Gmail connected through the workspace's own Google applicationNo: Google pushes only to a topic in the same Google Cloud project as the application. Read on the regular schedule
Microsoft 365 or Outlook, connected by its own sign-in (a person's own mailbox, or a shared mailbox's own account)Yes, once the installation has set up Microsoft push, whichever application it was connected through
A Microsoft shared mailbox reached through a member's sign-inNo (D6): Microsoft would need the tenant-wide Mail.Read application permission, which reaches every mailbox in the tenant, personal ones included. It is not asked for. Read on the regular schedule

Switching mail off stops every push within the hour (the workspace.mail_push job), and notices that still arrive are accepted and ignored. Switching it on again sets push up at each mailbox's next read, which also catches up on anything that arrived meanwhile. Disconnecting a mailbox, and a leaver's mailbox stopping, stop its push first. Uninstalling mail removes the installation's records of each push; any push still set up at Google or Microsoft runs out on its own (Google in seven days, Microsoft in three) and its notices are ignored.

When push fails (Google or Microsoft refuses to set it up, or cannot be reached), the mailbox stays connected and is read on the regular schedule; its screen says The provider is not telling us about new mail right now. It is tried again after five minutes, doubling to at most six hours. Nothing needs reconnecting for it.

What the operator sets up for push​

Push is off until the deployment's environment names it. Google, all three or none:

  1. In the same Google Cloud project as the installation's mailbox application (MAILBOX_GOOGLE_CLIENT_ID), enable the Cloud Pub/Sub API and create a topic, for example projects/<project>/topics/gmail-push. Set MAIL_PUSH_GOOGLE_TOPIC to its full name.
  2. On that topic, grant Pub/Sub Publisher to gmail-api-push@system.gserviceaccount.com (Gmail publishes as it). Without it, setting push up for a mailbox is refused and its screen says so.
  3. Create a service account for the push to sign as (it needs no role), and give the Pub/Sub service agent (service-<project number>@gcp-sa-pubsub.iam.gserviceaccount.com) Service Account Token Creator on it.
  4. Create a push subscription on the topic: endpoint https://<host>/api/v1/hooks/mail/google, authentication on with that service account, and an audience (the endpoint URL itself is the usual choice). Acknowledgement deadline 10 seconds or more; a retry policy with exponential back-off; message retention one day is plenty (each notice only says "read this mailbox").
  5. Set MAIL_PUSH_GOOGLE_AUDIENCE to that audience and MAIL_PUSH_GOOGLE_SERVICE_ACCOUNT to the service account's address.

Microsoft: set MAIL_PUSH_MICROSOFT_NOTIFICATION_URL to https://<host>/api/v1/hooks/mail/microsoft. It must be reachable from the internet over HTTPS with a certificate a public authority issued: Microsoft calls it to check it before any mailbox's push is set up, and posts each notice to it. Nothing is registered in Azure for it beyond the mailbox application the installation already has (its delegated Mail.ReadWrite covers it).

MAIL_PUSH_RATE_PER_MINUTE (6,000) is the most genuine notices each address takes a minute — Google's and Microsoft's are counted apart, and only notices that passed their check count; past it the address answers try again later, and the regular reading carries the mail. Notices that fail their check are limited separately, so somebody posting junk at one address cannot slow the other, nor use up what genuine notices are allowed. Raise it only for a very large installation.

The two addresses are public by design, as the bill mail address is: a notice is believed only once Google's signature (the subscription's own token, for the configured audience and service account) or the subscription's secret (Microsoft) checks, and even then it only asks for one mailbox to be read. Nothing in a notice is kept.

Changing the signing key (JWT_SECRET_KEY) changes how the installation recognises a Gmail notice: until each mailbox's push is next renewed (within a day), its notices are ignored and the regular reading carries its mail. Microsoft's push is not affected.

The mail worker (for the operator)​

Mail is sent and fetched by a worker of its own, apart from the rest of the background work, so a slow mail server never holds up anything else. The queue's depth is logged every minute beside the default queue's (worker.queue_depth, queue: mail).

Interactions​

  • Rooms and direct messages (workspace.chat) are separate: mail being off does not touch chat.
  • Company email (Settings, Integrations, Email) is the company's own sending connection and is not a workspace mailbox. Mailboxes do not appear on the Integrations screen.
  • Reading mail (H3b): each thread is a conversation of the mailbox, seen by the mailbox's people only. Working it (H3c) is the hub's Mail screen. Sending is H3d; push (H3e) is above.
  • Contacts (contact.read): the sender match offers only contacts the person may read; without contact.read, nothing is offered.