> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Inbound Mail

> Receive application email at an inbound address: managed SES by default, or your own provider.

Mount `@bijectionhq/app-mail` to receive mail at an inbound address. The
address is the mount's `inbound` [slot](https://docs.bijection.com/operate/placement.md)
(`inbound-mail@1`): at `mail`, it is `mail.inbound`. Unbound, it is managed
SES: the hosted operator provisions SES receipt rules, S3 staging and an SQS
queue, and the app polls through its own SigV4 receiver using a sealed,
short-lived reader session scoped to the receiver's queue and staging prefix.

To receive through your own SES account instead, name it as the managed
slot's account in the installation's bindings file:
`bind(app.mail.inbound, placement.managed({ account: placement.aws.ses({ region, queue, bucket, credential }) }))`
names the region of your receipt rule, the SQS queue SES notifies, the S3
bucket name from the rule's S3 action (`prefix` defaults to `mime/`) and the
secret path of the SigV4 reader session (`mail.readerSession`). Then deploy. The app,
its receivers and your `received` reaction do not change. See [placement](https://docs.bijection.com/operate/placement.md#the-bindings-file).

Reading a particular mailbox you already have, in Gmail, Microsoft 365 or an
IMAP server, is a connector, not placement: see the Gmail, Microsoft Graph and
IMAP integrations.

## Install and activate

`mail({ label, received })` returns the app to place at a path of your
tree. `received` is your reaction to one admitted message, a mutation under
the mail label whose args are `receivedArgs`.

```ts app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, mutation, role, t } from "@bijectionhq/bijection";
import { mail, receivedArgs } from "@bijectionhq/app-mail";

const inbox = label({ quotas: { holds: 16, queries: 16 } });

const onMail = mutation({ under: inbox, args: receivedArgs }, async () => null);
const installed = mail({ label: inbox, received: onMail });
const support = role({ clear: [inbox], include: [installed.reader], issue: true });

export const declareReceiver = mutation({ allow: [support] }, async (ctx) =>
  ctx.call(installed.receivers.declare, { receiver: "support" }));

export const grantReader = mutation({ allow: [support], under: inbox, args: { to: t.principal } }, async (ctx, { to }) => {
  await ctx.grant(installed.reader, { to, under: inbox });
});

export default app({ inbox, support, onMail, declareReceiver, grantReader, mail: installed });
```

Call `declareReceiver`, then have the deployment operator plan, bind and
activate the receiver through Mail's operator routes, binding against the
receiver revision the plan returns. The operator provisions the address and
sets and refreshes the reader session. See the
[Mail package operator and installer reference](https://github.com/bijectionhq/bijection/tree/main/npm-packages/apps/mail#install).

Mail submits `received` as a task under `inbox` once the message has
committed, so its failure or refusal is that task's result and never refuses
the message. The reading queries allow Mail's `reader` role. Your code grants
it directly with `ctx.grant(mail.reader, { to: subject, under: inbox, until })`.
The installer role admitted to that mutation declares `include: [mail.reader]`
and `issue: true`, so it holds the reader's rights and may hand them out.

## Limits and delivery semantics

* Each mount can open up to 64 receivers. The SES message ID deduplicates
  SQS redelivery while its message is retained. Queue acknowledgement
  deletes the exact SQS receipt. There is no historical replay cursor.
* Receiver names, addresses and control state are public to the mount.
  Message rows, in-flight answers and Files live under the mail label you
  pass. Reserve label capacity for polling, staging and retained
  Files, and storage for staged and final copies.
* The bounded S3 pull reads 36 KiB ranges. The raw message and up to 32
  attachment Files share an 8 MiB budget. Failed verdicts or oversized
  or malformed messages can produce envelope-only records.
* Your code can delete a message and retire its Files through Mail's
  internal message functions. This is a local operation. Closing or retiring a receiver fences new admissions.

End-to-end SES receiving remains unverified.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.