Record why an email send was rejected or failed
Merged
SI
16d ago+10+10+01234567890123456789-0-0-0123456789
Summary
Adds a nullable reason column to email_send_log, so a rejected or failed POST /api/emails attempt records why.
Why
Most logged sends (59% in the August investigation on recoupable/app#1949) were rejected, and the log could not say why: the rejected path stored only the raw body, and the earlier error column was dropped in 20260630211500 because nothing filled it. The companion api PR writes reason as a short code then detail (recipient_not_allowed: ā¦, invalid_body: html: ā¦, no_account_email, auth_failed: 401, resend_error: ā¦), so the rejection rate can be grouped by cause.
Notes
- Additive and nullable; existing rows and writers are unaffected.
- Merge and apply this before the api PR that writes the column.
š¤ Generated with Claude Code
Summary by cubic
Adds a nullable reason column to email_send_log so rejected or failed POST /api/emails attempts can record why.
- Most logged sends (59% in the recoupable/app#1949 investigation) were
rejectedwith nothing to say why; the earliererrorcolumn was dropped because nothing filled it. - The companion api PR writes
reasonas a short code followed by detail, e.g.recipient_not_allowed: ā¦, so rejection rate can be grouped by cause. - Additive and nullable; existing rows and writers are unaffected. Merge this before the api PR that writes the column.