# Mail sync

> Gmail, Outlook and other mailboxes synced per member through their own OAuth grant: threads and messages linked to the people and companies they involve, logged as email engagements, and a record of the mail members send, with opens and clicks per message and per template version.

- Category: CRM & sales
- Module: `mail-sync`
- Modes: `managed`
- Docs: https://bettersupabase.com/docs/blocks/mail-sync
- Page: https://bettersupabase.com/blocks/mail-sync

## Install

```bash
npx better-supabase add mail-sync
```

The command also installs `updated-at`, `tenant`, `access`, `subjects`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by mail-sync; add installs them too.
    "updated-at": {},
    tenant: {},
    access: {},
    subjects: {},
    // Modes: "managed". The default is "managed".
    "mail-sync": { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/mail-sync`.

## Events

- `mail_account.connected`
- `mail_account.disconnected`
- `mail_message.clicked`
- `mail_message.opened`
- `mail_message.received`
- `mail_message.sent`

## Related blocks

Requires: [tenant](https://bettersupabase.com/blocks/tenant.md), [access](https://bettersupabase.com/blocks/access.md), [subjects](https://bettersupabase.com/blocks/subjects.md)

Works with: [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md), [parties](https://bettersupabase.com/blocks/parties.md), [engagements](https://bettersupabase.com/blocks/engagements.md), [data-lifecycle](https://bettersupabase.com/blocks/data-lifecycle.md)
