Email Notifications
Automated, reliable email delivery with AWS SES integration, queue management, and a template system.
Architecture
| Component | Purpose |
|---|---|
| EmailService | Queue management and template rendering |
| SES Provider | AWS SES integration for delivery |
| Email Admin | 8 management endpoints for monitoring |
| Background Job | Processes queue every 2 minutes |
Data Flow
- User action triggers email (donation, password reset, etc.)
EmailService.queueEmail()inserts record intoemail_queue- Background job processes queue every 2 minutes
- Template rendered with dynamic data
- SES Provider sends email via AWS
- Status updated in queue, logged in
email_log - Failed emails retry automatically (up to 3 times)
Default Templates
| Template | Trigger |
|---|---|
donation_receipt | Sent after successful donation |
password_reset | Password reset request |
campaign_update | Campaign update notifications |
payout_notification | Payout 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 sessionUpdate 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
| Variable | Description |
|---|---|
AWS_SES_REGION | AWS region for SES |
AWS_SES_ACCESS_KEY | IAM access key |
AWS_SES_SECRET_KEY | IAM secret key |
SES_FROM_EMAIL | Verified sender address |