Clean-room Rust rewrite (written without reference to useSend source). Crates: mail-types, mail-core, mail-server, mail-auth, mail-submit, mail-hooks, mail-deliverability; sdks/ts (@scribase/mail); docs/. Each verified by running locally (see plans/scribase-mail-rust-2026-11-12.md). mail-mta, mail-inbound, mail-oci are still in progress and not in this commit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mail-deliverability
Deliverability monitoring and the public delivery record for Scribase Mail.
Library + mail-deliverability binary. Independent implementation, written
without reference to useSend source. Licence: MIT.
Reads mail-core's mail_* tables (and mail-inbound's inb_* when present)
read-only; owns the dlv_* tables in migrations/.
Jobs
| Job | What | Default interval |
|---|---|---|
blocklist |
sending IPs vs Spamhaus ZEN, Barracuda, SpamCop, SORBS, UCEPROTECT L1, PSBL; domains vs Spamhaus DBL, URIBL. Spamhaus 127.255.255.x answers are refused (public resolver / quota), never listed. |
1 h |
auth_health |
SPF (one record, valid, <= 10 lookups through include/redirect), DKIM selector published and equal to the key in mail_domains, DMARC policy, MTA-STS record + policy file, TLS-RPT, BIMI (optional), PTR/FCrDNS for sending IPs. |
1 h |
stats |
delivered/deferred/bounced/complained over 1h/24h/7d: overall, per recipient provider (gmail/outlook/yahoo/other by answering MX host or recipient domain), per sending domain, per API key; queue backlog age. Snapshots kept. | 5 min |
dmarc_reports |
pass rate per source IP from inb_*dmarc* tables, discovered via information_schema; "not available" with reason otherwise. |
1 h |
postmaster |
Google Postmaster Tools API v2: domainStats:query (SPAM_RATE, AUTH_SUCCESS_RATE, DELIVERY_ERROR_RATE, TLS_ENCRYPTION_RATE, daily, 7 days) + complianceStatus. No-op with a log line when no credentials. |
6 h |
Alerts
Rules: listed on a blocklist (critical), 24h complaint rate > 0.1% (critical),
24h bounce rate > 4% (warn), per-provider complaint rate > 0.1% (warn),
DKIM/SPF failing (critical), DMARC/PTR failing (warn), queue backlog > 10 min
(critical). Rate rules need DLV_MIN_SAMPLE sends (default 20).
State per rule key in dlv_alert_state; notifications only on
inactive->active ("fired") and active->inactive ("resolved"). History in
dlv_alert_history with the channels that succeeded. Channels: webhook URLs
(DLV_ALERT_WEBHOOK_URLS) and email via SMTP (DLV_ALERT_SMTP_*) or an HTTP
sender (DLV_ALERT_HTTP_URL = Resend-shaped POST /emails, e.g. our own
mail-server, with DLV_ALERT_HTTP_TOKEN).
Public delivery record
GET /status (HTML, light/dark, no scripts) and GET /status.json: last 30
days aggregated across all accounts: sent, accepted, bounce rate, complaint
rate, median queued->250 time, per-day table, blocklist status, auth status.
Only our configured domains/IPs appear in the blocklist and auth tables; no
per-customer data or addresses. Below DLV_STATUS_MIN_VOLUME (100) sends the
page shows counts and says rates are not published yet. Cached 60 s.
mail_deliverability::router(state) returns the axum router for mounting.
Run
export DATABASE_URL=postgres://localhost/mail_dev_dlv # mail-core migrated here
export DLV_RESOLVER=192.168.1.1 # NOT 1.1.1.1/8.8.8.8 (Spamhaus refuses them)
export DLV_SENDING_IPS=130.61.180.42,130.61.113.116
export DLV_DOMAINS=scribase.com,caldeskai.com
export DLV_ALERT_WEBHOOK_URLS=http://127.0.0.1:9798/alert
cargo run -p mail-deliverability -- run all # every job once, JSON per job
cargo run -p mail-deliverability # serve /status on BIND_ADDR (127.0.0.1:8791) + scheduler
Full env table in src/config.rs.
Owner-only steps
- Google Postmaster Tools: create a Google Cloud project, enable the
Postmaster Tools API, verify our domains in Postmaster Tools, add the
service account email as a user on each domain, then set
GOOGLE_POSTMASTER_SA_JSON=@/path/sa.json(or the refresh-token trio). - Spamhaus DQS key (free low-volume) for
DLV_SPAMHAUS_DQS_KEYso checks work from any resolver. - On box1 use the OCI resolver (
DLV_RESOLVER=169.254.169.254).