Prompt

How should I store email delivery status?

Technology / Api platforms2 observationsLast seen Nov 13, 2026

Latest observation

Nov 13, 2026OpenAI APIWeb search: off

A good rule is: store the delivery outcome as an immutable event log, and keep the current state as a small summarized record.

Recommended approach

1. Keep a per-recipient delivery record

If one email goes to multiple recipients, store status per recipient, not just per message.

Typical fields:

  • message_id / email_id
  • recipient
  • provider_message_id
  • status
    e.g. queued, sent, delivered, deferred, bounced, complained, opened, clicked
  • status_reason or error_code
  • status_detail / provider_response
  • timestamp
  • attempt_number
  • updated_at

2. Use a status model with clear lifecycle states

A simple lifecycle might be:

queued -> sent -> delivered with failure branches:

  • queued -> deferred -> sent
  • queued -> bounced
  • delivered -> complained

If you need analytics, track engagement separately:

  • opened
  • clicked
  • unsubscribed

3. Store events separately from current state

Best practice:

  • Event table: append-only log of all webhook/provider events
  • Current status table: one row per recipient/message with the latest known state

This helps with:

  • retries
  • auditing
  • deduplication
  • handling out-of-order provider webhooks

4. Make status updates idempotent

Email providers often send duplicate or out-of-order events. Store:

  • provider event ID
  • event timestamp
  • processed-at timestamp

Only update current state if the incoming event is newer or represents a valid transition.

5. Distinguish transport vs engagement

Don’t mix:

  • delivery: accepted by provider, sent, delivered, bounced
  • engagement: opened, clicked, unsubscribed

A message can be delivered but never opened.

Example schema

email_messages

  • id
  • subject
  • body
  • created_at

email_recipients

  • id
  • email_message_id
  • recipient_email
  • status
  • last_event_at
  • provider_message_id
  • failure_code
  • failure_reason
  • delivered_at
  • bounced_at
  • opened_at
  • clicked_at

email_delivery_events

  • id
  • email_recipient_id
  • provider_event_id
  • event_type
  • event_payload
  • occurred_at
  • received_at

If you want something simpler

For a small system, a single table can work:

  • status
  • status_updated_at
  • failure_reason
  • provider_message_id

But once you have webhooks, retries, or multiple providers, an event log becomes very valuable.

Practical advice

  • Use enum/status codes rather than free-text status strings.
  • Keep the raw provider payload for debugging.
  • Track one latest status plus history.
  • Separate recipient-level status from message-level status.

If you want, I can suggest a concrete SQL schema for Postgres or a model for a specific email provider like SES, SendGrid, or Postmark.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.