Skip to content

SES Module #138

@maxn990

Description

@maxn990

Background

Email functionality has been built from scratch on many C4C projects. A pre-built SES module in scaffolding would eliminate this repeated work and ensure consistent patterns.

Tasks

Create apps/backend/src/aws/ses/ with:

  • awsSesClient.factory.ts — provider factory that constructs a SESv2Client using AWS_REGION, asserting that AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION are defined at startup
  • awsSes.wrapper.tsAmazonSESWrapper service that accepts injected SESv2Client, builds raw MIME messages via nodemailer MailComposer, and sends via SendEmailCommand; supports recipient arrays and optional EmailAttachment[]
  • email.service.tsEmailsService that wraps AmazonSESWrapper with a Bottleneck rate limiter (14 emails/sec, maxConcurrent: 1) and gates all sends behind a SEND_AUTOMATED_EMAILS=true env var check, logging a warning instead of sending when disabled
  • email.module.ts — EmailsModule that provides AmazonSESWrapper, AmazonSESClientFactory, and EmailsService, exporting only EmailsService for use in other modules
  • Create a SendEmailDTO

Examples:

Add required env vars to example.env: AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SES_SENDER_EMAIL, SEND_AUTOMATED_EMAILS

Add a README.md inside the module directory documenting how to inject EmailsService, how to verify a sender identity in SES, and the behavior of the SEND_AUTOMATED_EMAILS flag

Acceptance Criteria

EmailsService can be injected into any other NestJS module via EmailsModule. The SEND_AUTOMATED_EMAILS flag correctly gates all sends.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions