Skip to content

Email Notifications

Automated, reliable email delivery with AWS SES integration, queue management, and a template system.

Architecture

ComponentPurpose
EmailServiceQueue management and template rendering
SES ProviderAWS SES integration for delivery
Email Admin8 management endpoints for monitoring
Background JobProcesses queue every 2 minutes

Data Flow

  1. User action triggers email (donation, password reset, etc.)
  2. EmailService.queueEmail() inserts record into email_queue
  3. Background job processes queue every 2 minutes
  4. Template rendered with dynamic data
  5. SES Provider sends email via AWS
  6. Status updated in queue, logged in email_log
  7. Failed emails retry automatically (up to 3 times)

Default Templates

TemplateTrigger
donation_receiptSent after successful donation
password_resetPassword reset request
campaign_updateCampaign update notifications
payout_notificationPayout processing alerts

API Examples

Send Donation Receipt

bash
POST /api/v1/emails/send
Content-Type: application/json

{
  "template": "donation_receipt",
  "to": "donor@example.com",
  "data": {
    "donor_name": "Jane Smith",
    "amount": 50.00,
    "fundraiser_title": "Help Local School"
  }
}

Get Email Queue (Admin)

bash
GET /api/v1/admin/emails/queue?status=pending
Authorization: Cookie session

Update Email Template (Admin)

bash
PUT /api/v1/admin/emails/templates/:id
Authorization: Cookie session
Content-Type: application/json

{
  "subject": "Thank you for your donation!",
  "html_body": "<h1>Thank you, {{donor_name}}!</h1>"
}

Configuration

Required Environment Variables

VariableDescription
AWS_SES_REGIONAWS region for SES
AWS_SES_ACCESS_KEYIAM access key
AWS_SES_SECRET_KEYIAM secret key
SES_FROM_EMAILVerified sender address

Built with VitePress