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

ComponentPath
Email clientbackend/src/lib/email/
Email templatesbackend/src/lib/email-templates/
Notification servicebackend/src/services/notification-service.ts
Template config tabledocumentObtainingEmailTemplates

Email Types

CategoryTriggerTemplate Location
Password resetUser requests resetemail-templates/
Magic link loginUser requests magic linkemail-templates/
Portal invitationAdmin creates portal accessemail-templates/
Document reminderAutomated follow-upemail-templates/
Document collectionNew document requestemail-templates/
Appointment notificationAppointment created/updatedemail-templates/
System notificationVarious system eventsemail-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:

  1. Route handler enqueues email job with template + recipient data
  2. Background Jobs processor picks up the job
  3. Resend API is called with rendered template
  4. 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