# Email Notifications — {{provider}}

## Overview
Transactional email system using {{provider}} sent from `{{from_address}}`, with template rendering, {{queue_enabled}} async queuing, and delivery tracking.

## Acceptance Criteria

### AC-1: Template Rendering
- Define email templates with subject and HTML/text body variants
- Interpolate dynamic variables (e.g. `{{user_name}}`, `{{action_url}}`) at send time
- Validate all required variables are provided before queuing

### AC-2: Sending via {{provider}}
- Send emails via {{provider}} API using environment-configured credentials
- Set `From: {{from_address}}` on all outgoing emails
- Handle API errors with retry logic (3 attempts, exponential backoff)

### AC-3: Async Queue
- When `queue_enabled` is {{queue_enabled}}, enqueue emails instead of sending synchronously
- Worker processes the queue and marks emails as `sent` or `failed`
- Retry failed sends up to 3 times before marking as permanently failed

### AC-4: Delivery Tracking
- Store delivery records: recipient, template, status, sentAt, provider message ID
- Expose delivery status via an internal admin API
- Alert when failure rate exceeds 5% in a 1-hour window

## Technical Notes
- Never log email body content — only metadata (recipient, template name, status)
- Implement unsubscribe links and honor opt-out preferences
- Test with {{provider}} sandbox/test mode before production deployment
