Skip to content
send.io
All posts
Reliability

Retry failed sends without sending twice

Combine durable jobs, stable message keys, and bounded retries to make email failures easier to recover from.

Retry failed sends without sending twice — illustrated Sendio guide
On this page

A timeout leaves an unanswered question

Your application sends a request, waits, and times out. Did the provider reject it, or accept it before the response was lost? Immediately creating a new message can turn an uncertain outcome into a duplicate email.

Assign one stable key to the business event that should produce the message. A receipt key might combine the payment ID and template version. Reuse that key for retries of the same logical send, and use a new key only for a deliberately new message.

Make deduplication durable

Enforce uniqueness in durable storage before a worker begins processing the job. An in-memory set disappears when the process restarts and does not coordinate multiple workers. If the provider supports idempotency keys, use them as well and check their retention window.

There is still a failure window between a provider accepting a request and your application recording the response. A database key alone cannot close that window. Provider idempotency or reconciliation is needed before promising exactly-once sending.

email_jobs.sqlsql
-- Illustrative application schema, not a provider API.
CREATE TABLE email_jobs (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  event_key text NOT NULL UNIQUE,
  state text NOT NULL DEFAULT 'queued',
  attempt_count integer NOT NULL DEFAULT 0
);

Bound the retry loop

Separate permanent validation failures from temporary problems. Use delayed retries with backoff and jitter, honor a valid Retry-After header when supplied, and cap both attempts and total age. A password reset email should not emerge from a retry queue after its link has expired.

When the policy is exhausted, preserve the job for investigation. A manual replay should show whether it is another attempt at the same send or a genuinely new message. That choice should be explicit.

Further reading

MDN: Retry-After