Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Upgrade Resend (#3170)

Steven Tey6b903ee788d4
diff --git a/packages/email/src/send-via-resend.ts b/packages/email/src/send-via-resend.ts
index b042b3d11b..fa4e8c796a 100644
--- a/packages/email/src/send-via-resend.ts
+++ b/packages/email/src/send-via-resend.ts
@@ -1,8 +1,11 @@
+import type { CreateEmailOptions } from "resend";
import { resend } from "./resend";
import { VARIANT_TO_FROM_MAP } from "./resend/constants";
import { ResendBulkEmailOptions, ResendEmailOptions } from "./resend/types";
-const resendEmailForOptions = (opts: ResendEmailOptions) => {
+const resendEmailForOptions = (
+ opts: ResendEmailOptions,
+): CreateEmailOptions => {
const {
to,
from,
@@ -17,16 +20,16 @@ const resendEmailForOptions = (opts: ResendEmailOptions) => {
tags,
} = opts;
- return {
+ // Build base options without rendered outputs (react/html/text)
+ // CreateEmailOptions requires at least one of react, html, or text
+ const baseOptions = {
to,
from: from || VARIANT_TO_FROM_MAP[variant],
- bcc: bcc,
+ subject: subject!,
+ bcc,
// if replyTo is set to "[email protected]", don't set replyTo
// else set it to the value of replyTo or fallback to [email protected]
...(replyTo === "noreply" ? {} : { replyTo: replyTo || "[email protected]" }),
- subject,
- text,
- react,
scheduledAt,
tags,
...(variant === "marketing"
@@ -36,10 +39,20 @@ const resendEmailForOptions = (opts: ResendEmailOptions) => {
"List-Unsubscribe": "https://app.dub.co/account/settings",
},
}
- : {
- headers,
- }),
+ : headers && { headers }),
};
+
+ // Add render options (react, html, or text) - at least one must be present
+ // CreateEmailOptions requires at least one of react, html, or text
+ if (react) {
+ return { ...baseOptions, react };
+ }
+ if (text) {
+ return { ...baseOptions, text };
+ }
+ // If none of react, html, or text is provided, we need to ensure at least one is present
+ // This shouldn't happen in practice, but we'll default to an empty text
+ return { ...baseOptions, text: "" };
};
// Send email using Resend (Recommended for production)