---
title: "Introducing Mail: the mind’s own read-only inbox"
summary: "A small member-only page for inbound and outbound mail already recorded by the mind, without copying a personal mailbox."
created: "2026-11-15"
updated: "2026-11-17"
revision: "5"
previous: "f231a42647829f9ab1e8e81f0bc25d36125e4db6"
reviewedThrough: "db9c004f146ca49dc313bc6b0a28d308d0d4b824"
sourceDigest: "d0e6e284289252361ec6f740b13a54d543ee657f0d5fd6ec21b08bbad05bccde"
---

With this, your mind can show its members the mail it has received and sent, in a browser. The useful constraint is what it does not do: this is not Gmail, a mail migration or a new delivery service. It is a read-only view of the mind’s existing email event stream. There is no compose button, attachment download, mailbox search or HTML renderer.

## Two files and a guarded host

The implementation is `apps/mail/app.ts` and `apps/mail/index.html`, mounted in `worker.ts` as a `mailApp()` instance. The page uses ordinary browser APIs and inline CSS and JavaScript. It imports no UI library and installs no npm package. The server imports only its own HTML file, whose text the config loader supplies. A commit publishes both files together.

```ts
import { mailApp } from "./apps/mail/app.ts";
const mail = mailApp();
// Inside the mind worker’s routing switch:
case "mail":
  return this.auth.require(request) || mail.fetch(request, this);
```

The guard is the important dependency. It must run before every route, including `/messages`, not merely before the HTML. `requirePerson` would be wrong: being signed in is not permission to read the team inbox. This app intentionally gives every member the same view; it has no per-person mailbox isolation. If that is not suitable for your mind, make a different data model before installing it. Never expose a member `itx` socket to a public reader.

## Read events, not a vendor mailbox

On `GET /messages?after=0`, the server reads up to 500 events after the cursor on the mind’s email integration context, `/integrations/email`. It keeps only `events.iterate.com/email/received` and `events.iterate.com/email/sent`. It projects offset, time, direction, sender, recipients, copied recipients, delivery-envelope recipient, subject, plain text and whether a message was HTML-only. It returns no raw event, header dump or attachment bytes. The delivery-envelope recipient is kept separately because an alias can make it differ from the visible To header; neither is a grant to send a reply.

```js
const page = await mailContext.readEvents(after, 500);
// Filter and project the two email event types here.
return Response.json({
  messages,
  after: page.scannedThroughOffset,
  atHead: page.atHead
}, { headers: { "cache-control": "private, no-store" } });
```

The cursor is a nonnegative safe integer; invalid input gets 400. The cursor must advance through all scanned events, even when a page contains no mail. Otherwise a client can loop forever on an unrelated event. The browser fetches until `atHead`, rejects a non-advancing cursor, sorts by offset newest first and filters incoming or outgoing locally. Refresh starts again from zero. That is deliberately simple and will need incremental loading or virtualization for a very large history.

## Mail is hostile content

The browser builds elements with `textContent`, including the subject and body. Opening a disclosure lazily adds its plain-text body. An HTML-only message gets an explanatory label, never an iframe or `innerHTML`. The server refuses non-GET methods and marks both HTML and JSON private and non-cacheable. Its content-security policy restricts connections to the same origin and forbids frames, objects, base URLs and framing by another page. Inline scripts and styles are allowed because the page is one file; importing an external script would require revisiting that policy.

## Reading mail does not authorize an agent turn

Inbound delivery has a separate boundary in `apps/mail-door/mail-door.ts`, called from the email case in `worker.ts`. Under the default closed policy, an outside person's or another mind's reply is handed only to an agent whose script runner is routed into a recognized jail. Pausing a full-authority agent does not count as isolation. If routing inspection fails, the decision stays closed: keep the mail on the private integration log and append one deduplicated held-reply record for a member to inspect. Proven member mail follows the member route. This is separate from rendering the inbox, which can still show recorded mail without starting an agent. When adapting delivery, retain this default, test failures and duplicate events, and treat quoted content as untrusted even in a proven member's message.

## Adapting it into another mind

Bring the two source files into your own config, import and mount them in your existing worker style, and retain member authentication on both routes. Change the title from company branding to your own. You need an iterate mind with its normal email integration and permission to read its existing recorded events. You need no Google account, Gmail OAuth grant, new secret, subscription, database, background schedule or email send permission just to display mail. The page creates no storage of its own; browser memory holds the fetched projection. Existing email delivery remains wherever your mind already implements it.

Test a signed-out browser, a signed-in nonmember and a member; invalid and non-advancing cursors; empty pages; both directions; HTML-only mail; and subjects containing HTML-like text. Confirm that a POST cannot compose or mutate anything. Do not copy this company’s event history, subscribers, account links or credentials. A personal mind will show only the mail recorded by that personal mind, not mail sent outside it. [The blog recipe](/introducing/blog) explains how this page stays current; [the Dash](/introducing/dash) is the member’s wider control panel.
