Email & Notifications
Purpose
Design how the system sends transactional email (and adjacent notifications): provider, templates, async sending, deliverability, and the feedback loop (bounces/complaints) — without letting public flows turn the sender into a spam cannon.
When to Use
- For verification, password reset, receipts, alerts, digests, and similar transactional sends.
- Not for marketing-campaign tooling (different product class) or push-notification platforms (client packs / their own integration).
Inputs
- Notification inventory: trigger, audience, urgency, content per message type.
- Provider constraints/preferences; sending domain ownership.
Discovery Questions
- Which messages exist, and which are critical-path (verification, reset) vs best-effort (digest)?
- Who owns the sending domain, and can DNS records (SPF/DKIM/DMARC) be set?
- Which sends are triggered by public endpoints (signup, reset, contact) — abuse exposure?
- Do users need preferences/unsubscribe for non-essential messages?
Responsibilities
- Choose the provider as a vendor decision (
third-party-integrations rules: isolation, keys, sandbox/sink in non-prod so staging never emails real users).
- Manage templates: versioned in the repo (or provider-side with a recorded sync story), variables typed/validated, plain-text alternative, consistent sender identities per message class.
- Send asynchronously via
background-jobs: retries with backoff; critical sends (reset, verification) get must-happen treatment + idempotency (no double-send on retry storms; dedupe keys per logical send).
- Plan deliverability: SPF/DKIM/DMARC on the sending domain, separate transactional identity from any marketing traffic, warm-up awareness for new domains.
- Handle bounces/complaints via provider webhooks (
webhooks): suppression list enforced before every send; hard bounces stop future sends.
- Guard abuse: sends triggered by public endpoints (signup, reset, OTP, contact) sit behind
rate-limiting + captcha-abuse-prevention — email-sending endpoints are toll-fraud and spam vectors.
- Respect preferences: essential/security messages always send; everything else honors user settings + unsubscribe.
Required Workflow
- Build the message inventory (trigger, criticality, audience, identity).
- Choose provider + environment sink strategy.
- Design template management + validation.
- Wire async sending with per-class retry/idempotency.
- Set up deliverability records + bounce/complaint suppression.
- Confirm abuse protection on triggering endpoints.
- Specify tests: template variables validated, suppression respected, no duplicate critical sends, staging sends hit the sink.
Decision Rules
- Critical-path emails (verification/reset) are must-happen jobs with monitoring; a digest may drop, a reset email may not.
- Non-prod environments never send to real addresses — sink/allowlist enforced at the client wrapper, not by discipline.
- Reset/verification emails don't reveal account existence in triggering-endpoint responses (
backend-authentication).
- One logical send = one idempotency key; retries re-attempt delivery, not re-decide sending.
Rules
- All sends go through the isolated provider client — no inline SMTP calls in handlers.
- Suppression list checked on every send path.
- Templates never interpolate unvalidated user HTML (injection into email).
Anti-Patterns
- Sending inline in the request (slow + lost on failure).
- Staging accidentally emailing production users.
- Ignoring bounces until the provider suspends the account.
- Public reset endpoint without rate limit/CAPTCHA — attacker-driven mail bombing.
- Critical and bulk mail on one identity, digests dragging reset deliverability down.
Validation Checklist
Definition of Done
A recorded email design — provider isolation with environment sinks, versioned validated templates, idempotent async sending per criticality class, deliverability records, suppression handling, and abuse-protected triggers.
Related Skills
third-party-integrations, background-jobs, webhooks (bounce events), rate-limiting, captcha-abuse-prevention, backend-authentication (verification/reset flows), backend-observability.
Related Knowledge
../../../knowledge/ (message inventory, domain ownership).
Related References
../../../references/backend/integrations/ (provider/template notes, when populated).
Context Loading Guidance
- Requires: message inventory, provider constraints, triggering-endpoint list.
- Does not require: template copywriting, marketing tooling.
- May load:
background-jobs (send jobs), webhooks (feedback loop).
- Stop when: the send pipeline + deliverability + abuse design is recorded.
Token Efficiency Guidance
The message-inventory table (trigger, class, retry, identity) drives the design; keep deliverability to the checklist, not an email-infrastructure essay.
1---2name: email-notifications3description: Use to plan transactional email and notification delivery — provider choice, template management, sending via background jobs, deliverability (SPF/DKIM/DMARC), bounce/complaint handling, and abuse-safe triggering.4---56# Email & Notifications78## Purpose910Design how the system sends transactional email (and adjacent notifications): provider, templates, async sending, deliverability, and the feedback loop (bounces/complaints) — without letting public flows turn the sender into a spam cannon.1112## When to Use1314- For verification, password reset, receipts, alerts, digests, and similar transactional sends.15- **Not** for marketing-campaign tooling (different product class) or push-notification platforms (client packs / their own integration).1617## Inputs1819- Notification inventory: trigger, audience, urgency, content per message type.20- Provider constraints/preferences; sending domain ownership.2122## Discovery Questions2324- Which messages exist, and which are critical-path (verification, reset) vs best-effort (digest)?25- Who owns the sending domain, and can DNS records (SPF/DKIM/DMARC) be set?26- Which sends are triggered by public endpoints (signup, reset, contact) — abuse exposure?27- Do users need preferences/unsubscribe for non-essential messages?2829## Responsibilities3031- Choose the provider as a vendor decision (`third-party-integrations` rules: isolation, keys, sandbox/sink in non-prod so staging never emails real users).32- Manage templates: versioned in the repo (or provider-side with a recorded sync story), variables typed/validated, plain-text alternative, consistent sender identities per message class.33- Send **asynchronously** via `background-jobs`: retries with backoff; critical sends (reset, verification) get must-happen treatment + idempotency (no double-send on retry storms; dedupe keys per logical send).34- Plan deliverability: SPF/DKIM/DMARC on the sending domain, separate transactional identity from any marketing traffic, warm-up awareness for new domains.35- Handle **bounces/complaints** via provider webhooks (`webhooks`): suppression list enforced before every send; hard bounces stop future sends.36- Guard abuse: sends triggered by public endpoints (signup, reset, OTP, contact) sit behind `rate-limiting` + `captcha-abuse-prevention` — email-sending endpoints are toll-fraud and spam vectors.37- Respect preferences: essential/security messages always send; everything else honors user settings + unsubscribe.3839## Required Workflow40411. Build the message inventory (trigger, criticality, audience, identity).422. Choose provider + environment sink strategy.433. Design template management + validation.444. Wire async sending with per-class retry/idempotency.455. Set up deliverability records + bounce/complaint suppression.466. Confirm abuse protection on triggering endpoints.477. Specify tests: template variables validated, suppression respected, no duplicate critical sends, staging sends hit the sink.4849## Decision Rules5051- Critical-path emails (verification/reset) are must-happen jobs with monitoring; a digest may drop, a reset email may not.52- Non-prod environments never send to real addresses — sink/allowlist enforced at the client wrapper, not by discipline.53- Reset/verification emails don't reveal account existence in triggering-endpoint responses (`backend-authentication`).54- One logical send = one idempotency key; retries re-attempt delivery, not re-decide sending.5556## Rules5758- All sends go through the isolated provider client — no inline SMTP calls in handlers.59- Suppression list checked on every send path.60- Templates never interpolate unvalidated user HTML (injection into email).6162## Anti-Patterns6364- Sending inline in the request (slow + lost on failure).65- Staging accidentally emailing production users.66- Ignoring bounces until the provider suspends the account.67- Public reset endpoint without rate limit/CAPTCHA — attacker-driven mail bombing.68- Critical and bulk mail on one identity, digests dragging reset deliverability down.6970## Validation Checklist7172- [ ] Message inventory with criticality + identity per class.73- [ ] Provider isolated; non-prod sink enforced.74- [ ] Templates versioned, variables validated, text alternative.75- [ ] Async sends with retry + idempotency per class.76- [ ] SPF/DKIM/DMARC planned; bounce/complaint suppression wired.77- [ ] Triggering public endpoints abuse-protected.7879## Definition of Done8081A recorded email design — provider isolation with environment sinks, versioned validated templates, idempotent async sending per criticality class, deliverability records, suppression handling, and abuse-protected triggers.8283## Related Skills8485`third-party-integrations`, `background-jobs`, `webhooks` (bounce events), `rate-limiting`, `captcha-abuse-prevention`, `backend-authentication` (verification/reset flows), `backend-observability`.8687## Related Knowledge8889`../../../knowledge/` (message inventory, domain ownership).9091## Related References9293`../../../references/backend/integrations/` (provider/template notes, when populated).9495## Context Loading Guidance9697- **Requires:** message inventory, provider constraints, triggering-endpoint list.98- **Does not require:** template copywriting, marketing tooling.99- **May load:** `background-jobs` (send jobs), `webhooks` (feedback loop).100- **Stop when:** the send pipeline + deliverability + abuse design is recorded.101102## Token Efficiency Guidance103104The message-inventory table (trigger, class, retry, identity) drives the design; keep deliverability to the checklist, not an email-infrastructure essay.