Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
DATABASE_NAME_TEST: securing-safe-food-test
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
SEND_AUTOMATED_EMAILS: 'true'
NX_DAEMON: 'false'
CYPRESS_INSTALL_BINARY: '0'
steps:
Expand Down
3 changes: 3 additions & 0 deletions apps/backend/src/emails/awsSes.wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export class AmazonSESWrapper {
const messageData = await new MailComposer(mailOptions).compile().build();

const command = new SendEmailCommand({
Destination: {
ToAddresses: recipientEmails,
},
Content: {
Raw: {
Data: messageData,
Expand Down
6 changes: 5 additions & 1 deletion apps/backend/src/emails/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class EmailsService {
* @param recipientEmail the email address of the recipients
* @param subject the subject of the email
* @param bodyHtml the HTML body of the email
* @param attachments any base64 encoded attachments to inlude in the email
* @param attachments any base64 encoded attachments to include in the email
* @resolves if the email was sent successfully
* @rejects if the email was not sent successfully
*/
Expand All @@ -31,6 +31,10 @@ export class EmailsService {
bodyHTML: string,
attachments?: EmailAttachment[],
): Promise<unknown> {
if (process.env.SEND_AUTOMATED_EMAILS === 'false') {
this.logger.warn('Automated emails are disabled. Email not sent.');
return Promise.resolve();
}
return this.amazonSESWrapper.sendEmails(
recipientEmails,
subject,
Expand Down
102 changes: 102 additions & 0 deletions apps/backend/src/emails/emailTemplates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
export type EmailTemplate = {
subject: string;
bodyHTML: string;
additionalContent?: string;
};

export const EMAIL_REDIRECT_URL = 'localhost:4200';
// TODO: Change this before production to be the actual ssf email
export const SSF_PARTNER_EMAIL = 'example@gmail.com';

export const emailTemplates = {
pantryFmApplicationApproved: (params: { name: string }): EmailTemplate => ({
subject: 'Your Securing Safe Food Account Has Been Approved',
bodyHTML: `
<p>Hi ${params.name},</p>
<p>
We're excited to let you know that your Securing Safe Food account has been
approved and is now active. You can now log in using the credentials created
during registration to begin submitting requests, managing donations, and
coordinating with our network.
</p>
<p>
If you have any questions as you get started or need help navigating the
platform, please do not hesitate to reach out — we are happy to help!
</p>
<p>
We are grateful to have you as part of the SSF community and look forward
to working together to expand access to allergen-safe food.
</p>
<p>Best regards,<br />The Securing Safe Food Team</p>
`,
}),

volunteerAccountCreated: (): EmailTemplate => ({
subject: 'Welcome to Securing Safe Food: Your Volunteer Account Is Ready',
bodyHTML: `
<p>Welcome to Securing Safe Food!</p>
<p>
Your volunteer account has been successfully created and you can now log in
to begin supporting pantry coordination, order matching, and delivery logistics.
</p>
<p>
Once logged in, you'll be able to view your assignments, track active requests,
and collaborate with partner organizations.
</p>
<p>
Thank you for being part of our mission. Your time and effort directly help
increase access to safe food for individuals with dietary restrictions.
</p>
<p>Best regards,<br />The Securing Safe Food Team</p>
<p>
To log in to your account, please click the following link: <a href="${EMAIL_REDIRECT_URL}/login">${EMAIL_REDIRECT_URL}/login</a>
</p>
`,
}),

pantryFmApplicationSubmittedToAdmin: (): EmailTemplate => ({
subject: 'New Partner Application Submitted',
bodyHTML: `
<p>Hi,</p>
<p>
A new partner application has been submitted through the SSF platform.
Please log in to the dashboard to review and take action.
</p>
<p>Best regards,<br />The Securing Safe Food Team</p>
<p>
To review this application, please enter the admin pantry approval dashboard: <a href="${EMAIL_REDIRECT_URL}/approve-pantries">${EMAIL_REDIRECT_URL}/approve-pantries</a>
</p>
`,
}),

pantryFmApplicationSubmittedToUser: (params: {
name: string;
}): EmailTemplate => ({
subject: 'Your Application Has Been Submitted',
bodyHTML: `
<p>Hi ${params.name},</p>
<p>
Thank you for your interest in partnering with Securing Safe Food!
Your application has been successfully submitted and is currently under review. We will notify you via email once a decision has been made.
</p>
<p>Best regards,<br />The Securing Safe Food Team</p>
`,
}),

pantrySubmitsFoodRequest: (params: {
pantryName: string;
volunteerName: string;
}): EmailTemplate => ({
subject: `${params.pantryName} Request Requires Your Review`,
bodyHTML: `
<p>Hi ${params.volunteerName},</p>
<p>
A new food request has been submitted by ${params.pantryName}.
Please log on to the SSF platform to review these request details and begin coordination when ready.
</p>
<p>
Thank you for your continued support of our network and mission!.
<p>Best regards,<br />The Securing Safe Food Team</p>
`,
}),
};
Loading
Loading