From 77a255ba72565dde54a48db34247f2830df7a6d3 Mon Sep 17 00:00:00 2001 From: Bianca Date: Mon, 7 Sep 2026 13:07:51 +0200 Subject: [PATCH 1/8] feat: add custom email sending functionality --- src/emails/mailer.tsx | 16 ++++++++++++ src/emails/templates/custom.tsx | 37 +++++++++++++++++++++++++++ src/routers/azure/members.ts | 45 ++++++++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/emails/templates/custom.tsx diff --git a/src/emails/mailer.tsx b/src/emails/mailer.tsx index 2dfb4f7..9c3e7bb 100644 --- a/src/emails/mailer.tsx +++ b/src/emails/mailer.tsx @@ -6,6 +6,7 @@ import { env } from "@/env" import { logger } from "@/logger" import OtpEmail from "./templates/otp" import Welcome from "./templates/welcome" +import CustomMessageEmail from "./templates/custom" const makeSubject = (subject: string) => (env.NODE_ENV === "development" ? `[DEV] ${subject}` : subject) @@ -51,3 +52,18 @@ export async function sendWelcomeEmail( /> ) } + +export async function sendCustomEmail( + toAddress: string, + content: { subject: string; body: string }, + firstName: string +) { + const customSubject = makeSubject(content.subject) + return sendEmail( + toAddress, + customSubject, + ) +} \ No newline at end of file diff --git a/src/emails/templates/custom.tsx b/src/emails/templates/custom.tsx new file mode 100644 index 0000000..67ccd6f --- /dev/null +++ b/src/emails/templates/custom.tsx @@ -0,0 +1,37 @@ +import { Footer } from "@/emails/components/footer"; +import { Logo } from "@/emails/components/logo"; +import { EmailTemplate } from "@/emails/types"; +import { Html, Tailwind, pixelBasedPreset, Head, Preview, Body, Container, Heading, Section, Text } from "@react-email/components"; + +type Props = { firstName: string; subject: string; body: string } + +const CustomMessageEmail: EmailTemplate = (props) => { + const paragraphs = props.body.split(/\n{2,}/).filter(p => p.trim()) + return ( + + + + {props.subject} + + + + {props.subject} +
+ Dear {props.firstName}, + {paragraphs.map((p, i) => {p})} +
+
+