Description
Users currently receive no email notifications for key platform events. We need an email service that sends transactional emails for course enrollment confirmations, credential issuance, payment receipts, assignment feedback, and account security alerts.
Definition of Done
- Email service abstraction with pluggable provider (starting with SendGrid or AWS SES)
- HTML email templates for: enrollment confirmation, credential issued, payment receipt, assignment graded, password changed, new login alert
- Templates use responsive HTML with plain-text fallback
- Email sending is async/non-blocking: queued via the existing transaction queue
- Retry with exponential backoff (3 attempts max) on send failure
- Email preference management: users can opt out of specific email types in Settings
- Rate limiting: max X emails per user per hour to prevent spam
- Email events tracked (sent, delivered, opened, bounced) for analytics
- Admin can trigger manual resend of specific email types
Files to Modify
- NEW:
backend/src/services/emailService.ts
- NEW:
backend/src/services/emailTemplates.ts
- NEW:
backend/src/services/__tests__/emailService.test.ts
- NEW:
backend/src/templates/emails/ (directory for HTML templates)
backend/src/services/notificationService.ts (add email channel)
backend/src/controllers/userController.ts (trigger emails on events)
backend/src/controllers/EnrollmentController.ts
backend/src/controllers/PaymentController.ts
backend/src/controllers/assignmentController.ts
backend/src/models/User.ts (add email preferences field)
backend/SETUP_GUIDE.md (add EMAIL_PROVIDER, SENDGRID_API_KEY, EMAIL_FROM to env var documentation)
Acceptance Criteria
Description
Users currently receive no email notifications for key platform events. We need an email service that sends transactional emails for course enrollment confirmations, credential issuance, payment receipts, assignment feedback, and account security alerts.
Definition of Done
Files to Modify
backend/src/services/emailService.tsbackend/src/services/emailTemplates.tsbackend/src/services/__tests__/emailService.test.tsbackend/src/templates/emails/(directory for HTML templates)backend/src/services/notificationService.ts(add email channel)backend/src/controllers/userController.ts(trigger emails on events)backend/src/controllers/EnrollmentController.tsbackend/src/controllers/PaymentController.tsbackend/src/controllers/assignmentController.tsbackend/src/models/User.ts(add email preferences field)backend/SETUP_GUIDE.md(add EMAIL_PROVIDER, SENDGRID_API_KEY, EMAIL_FROM to env var documentation)Acceptance Criteria