Resend Email
Transactional email delivery via the Resend API. Handles all outbound email communication including password resets, portal notifications, document reminders, and system alerts.
Architecture
| Component | Path |
|---|---|
| Email client | backend/src/lib/email/ |
| Email templates | backend/src/lib/email-templates/ |
| Notification service | backend/src/services/notification-service.ts |
| Template config table | documentObtainingEmailTemplates |
Email Types
| Category | Trigger | Template Location |
|---|---|---|
| Password reset | User requests reset | email-templates/ |
| Magic link login | User requests magic link | email-templates/ |
| Portal invitation | Admin creates portal access | email-templates/ |
| Document reminder | Automated follow-up | email-templates/ |
| Document collection | New document request | email-templates/ |
| Appointment notification | Appointment created/updated | email-templates/ |
| System notification | Various system events | email-templates/ |
Admin-Configurable Templates
The documentObtainingEmailTemplates table allows admins to customize email content for Document Obtaining workflows without code changes. Managed via Admin Dashboard.
Background Processing
Emails are sent asynchronously via the notification queue to avoid blocking request handlers:
- Route handler enqueues email job with template + recipient data
- Background Jobs processor picks up the job
- Resend API is called with rendered template
- Success/failure is logged
This ensures email delivery failures do not affect API response times.
Template Rendering
Templates use bilingual content following the Internationalization pattern. The recipient’s preferred language determines which version is sent.
Error Handling
- Failed sends are retried by the job processor (configurable retry count)
- Permanent failures are logged and reported to Sentry
- Bounce/complaint webhooks from Resend update delivery status
Related
- Notifications — Notification dispatch architecture
- Portal — Portal invitation emails
- Document Obtaining — Document reminder emails
- Authentication — Password reset and magic link emails
- Background Jobs — Async email processing queue
- External Integrations — All third-party integrations
- Sentry — Delivery failure tracking