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.ts — AmazonSESWrapper service that accepts injected SESv2Client, builds raw MIME messages via nodemailer MailComposer, and sends via SendEmailCommand; supports recipient arrays and optional EmailAttachment[]
email.service.ts — EmailsService 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.
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 aSESv2ClientusingAWS_REGION, asserting thatAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, andAWS_REGIONare defined at startupawsSes.wrapper.ts—AmazonSESWrapperservice that accepts injectedSESv2Client, builds raw MIME messages vianodemailerMailComposer, and sends viaSendEmailCommand; supports recipient arrays and optionalEmailAttachment[]email.service.ts—EmailsServicethat wrapsAmazonSESWrapperwith a Bottleneck rate limiter (14 emails/sec, maxConcurrent: 1) and gates all sends behind aSEND_AUTOMATED_EMAILS=trueenv var check, logging a warning instead of sending when disabledemail.module.ts— EmailsModule that providesAmazonSESWrapper,AmazonSESClientFactory, andEmailsService, exporting onlyEmailsServicefor use in other modulesSendEmailDTOExamples:
Add required env vars to example.env:
AWS_REGION,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SES_SENDER_EMAIL,SEND_AUTOMATED_EMAILSAdd a
README.mdinside the module directory documenting how to inject EmailsService, how to verify a sender identity in SES, and the behavior of theSEND_AUTOMATED_EMAILSflagAcceptance Criteria
EmailsServicecan be injected into any other NestJS module viaEmailsModule. TheSEND_AUTOMATED_EMAILSflag correctly gates all sends.