Skip to content

[SSF 109]: Email automation spike#84

Open
dburkhart07 wants to merge 38 commits intomainfrom
ddb/SSF-109-email-automation-spike
Open

[SSF 109]: Email automation spike#84
dburkhart07 wants to merge 38 commits intomainfrom
ddb/SSF-109-email-automation-spike

Conversation

@dburkhart07
Copy link

ℹ️ Issue

Closes #109

📝 Description

This ticket creates an initial part of our email automation. This was actually very straightforward, and followed a similar architecture that JPAL uses. To get this working, I needed to verify my email on AWS SES, which can be done through the following:

  1. Go into AWS SES
  2. Click on Identities in the sidebar
  3. Click create identity
  4. Add the email that you want to send with
  5. Create this new identity
  6. This is now the email that we can set as our new environment variable, AWS_SES_SENDER_EMAIL (all sender emails must be verified). THIS WILL BE UPDATED IN THE README AFTER WE MERGE IN THE ENVIRONMENT VARIABLE PR.

Additionally, here is some logic of what each of the file's purposes serve:
awsSesClient.factory.ts serves as the main configuration for the SES Client. It provides the user's access key and id to allow them to use the service API. It also provides a client to be injected later on.
awsSes.wrapper.ts injects this factory into the constructor, making it a valid client that has all SES functionality. This allows us to easily setup the proper parameters to send an email with varying complexity (supporting image attachments as well).
email.service.ts provides the service function that we will actually be calling with our API. All controllers will likely need to use this in their module which we have setup. This allows them to send a simple DTO and send an email just like that.

✔️ Verification

I made sure that we could send emails as is, as well as one with email attachments. I created a dummy endpoint for right now in the pantries.controller.ts file.

image image

🏕️ (Optional) Future Work / Notes

The emails are currently being marked as spam for some reason, not qutie sure as to why yet. Perhaps there is an AWS setting to change that.

Copy link
Member

@maxn990 maxn990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of super quick things, but overall looks really good!! 🥳 🥳 🥳

Comment on lines 311 to 317

@Post('/email')
async sendEmail(@Body() sendEmailDTO: SendEmailDTO): Promise<void> {
const { toEmail, subject, bodyHtml, attachments } = sendEmailDTO;

await this.emailsService.sendEmail(toEmail, subject, bodyHtml, attachments);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be a public route. right now this would mean that, once deployed, anyone who could access the api could send unlimited emails from our aws account. if you've finished role based auth, i would recommend adding a guard, otherwise commenting this out for now

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was going to be changed after we merged in the role based auth. i can just comment it out and whoever tests this next can uncomment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, either way works

Comment on lines 50 to 63
public async sendEmail(
recipientEmail: string,
subject: string,
bodyHTML: string,
attachments?: EmailAttachment[],
): Promise<unknown> {
return this.amazonSESWrapper.sendEmails(
[recipientEmail],
subject,
bodyHTML,
attachments,
);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason the method name here, sendEmail, is singular but it is a wrapper for sendEmails, which is plural?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

realized there was a mistake with the recipientEmails not accepting multiple. just fixed it.

@dburkhart07 dburkhart07 requested a review from maxn990 February 14, 2026 02:21
Copy link
Member

@maxn990 maxn990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🥳 🥳 💯 💯

Comment on lines 311 to 317

@Post('/email')
async sendEmail(@Body() sendEmailDTO: SendEmailDTO): Promise<void> {
const { toEmail, subject, bodyHtml, attachments } = sendEmailDTO;

await this.emailsService.sendEmail(toEmail, subject, bodyHtml, attachments);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way

Comment on lines 311 to 317

@Post('/email')
async sendEmail(@Body() sendEmailDTO: SendEmailDTO): Promise<void> {
const { toEmail, subject, bodyHtml, attachments } = sendEmailDTO;

await this.emailsService.sendEmail(toEmail, subject, bodyHtml, attachments);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, either way works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants