# v389 — CORI Mail Approved-Send Execution Foundation

## Purpose

v389 returns to CORI Mail after completing the v382-v388 notification track. The goal is to move CORI Mail from review-only send staging into a guarded approved-send path that can use a connected company email account when live send is enabled.

## Decision

v388 completed the simple app-style notification behavior that was needed before switching tracks. Notifications now have read/unread, hide, and restore behavior. The better next move is to return to CORI Mail approved-send execution instead of adding digest/email trigger behavior immediately.

## What changed

- Added a guarded CORI Mail approved-send service.
- Added `/api/cori-mail/approved-send`.
- Added CORI Mail send readiness checks based on connected company email in Workspace Integrations.
- Added final approval handling from `/cori/mail`.
- Added live Custom SMTP send execution for approved CORI Mail replies when `CORI_MAIL_SEND_ENABLED=true`.
- Added audit records for approved, queued, sent, failed, and send-locked CORI Mail send attempts.
- Updated CORI Mail memory counts so send review can show approved and sent totals.
- Extended the Custom SMTP sender to include CC recipients when a CORI Mail reply has a CC value.
- Kept company email setup, SMTP credentials, and provider testing in `/company/integrations`.

## User-facing behavior

At `/cori/mail`, users still review the important email, read CORI's plain explanation, edit the suggested answer, and create work cards.

The send area now has a clearer final approval panel:

- If company email is not connected, the page explains that email must be connected in Workspace Settings.
- If company email is connected but live send is still locked, the page allows review but does not send.
- If company email is connected and live send is enabled, the user can click **Approve and send now**.
- Every approved-send attempt is recorded in the CORI Mail send audit table.

## Safety rule

CORI Mail does not send automatically. The user must review the exact message and click the final approval button. Provider credentials stay out of CORI Mail and remain in Workspace Settings.

## Technical notes

New files:

- `src/modules/cori-mail/cori-mail-approved-send.service.ts`
- `app/api/cori-mail/approved-send/route.ts`

Updated files:

- `app/(dashboard)/cori/mail/page.tsx`
- `src/modules/cori-mail/cori-mail-persistence.service.ts`
- `src/modules/integrations/custom-smtp-connection.service.ts`
- `CHANGELOG.md`
- `DISPATCH_SPOT_BUILD_RULES.md`

## Prisma schema impact

No Prisma schema changes. v389 uses the existing CORI Mail draft, send audit, and Workspace Integration tables.
