Set up the D1 schema
The inbox lives in your Cloudflare D1 database. Apply this schema once with wrangler d1 execute before you send the first message, and the Worker will start writing every inbound envelope into the same rows your dashboard reads.
CREATE TABLE IF NOT EXISTS messages (
id TEXT PRIMARY KEY,
mailbox TEXT NOT NULL,
from_address TEXT NOT NULL,
to_address TEXT NOT NULL,
subject TEXT,
body_text TEXT,
body_html TEXT,
received_at INTEGER NOT NULL,
thread_id TEXT
);
CREATE INDEX IF NOT EXISTS idx_messages_mailbox
ON messages(mailbox, received_at DESC);