From 6ecd27decb1d5c7018114d1492f33847ed658a95 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 18 Oct 2025 02:39:10 +0000 Subject: [PATCH] Extend email service with sendInviteEmail cgen-13ed33f76f074fc2a51b65a0371fe642 --- server/email.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/server/email.ts b/server/email.ts index ceb8d0d7..f1ad8e5c 100644 --- a/server/email.ts +++ b/server/email.ts @@ -67,4 +67,51 @@ export const emailService = { reply_to: verifySupportEmail, }); }, + + async sendInviteEmail(params: { + to: string; + inviteUrl: string; + inviterName?: string | null; + message?: string | null; + }) { + if (!resendClient) { + throw new Error("Email service is not configured. Set RESEND_API_KEY."); + } + + const { to, inviteUrl, inviterName, message } = params; + const safeInviter = inviterName?.trim() || "An AeThex member"; + + const subject = `${safeInviter} invited you to collaborate on AeThex`; + + const html = ` +
+

You're invited to AeThex

+

${safeInviter} sent you an invitation to connect and collaborate on AeThex.

+ ${message ? `
${message}
` : ""} +

+ Accept invitation +

+

If the button does not work, paste this link into your browser:

+

${inviteUrl}

+
+ `; + + const text = [ + `You're invited to AeThex by ${safeInviter}.`, + message ? `\nMessage: ${message}` : "", + "\nAccept here:", + inviteUrl, + ].join("\n"); + + await resendClient.emails.send({ + from: defaultFromAddress, + to, + subject, + html, + text, + headers: { "X-AeThex-Email": "invite" }, + tags: [{ name: "template", value: "invite" }], + reply_to: verifySupportEmail, + }); + }, };