continued the kita-planer
This commit is contained in:
+6
-2
@@ -1,13 +1,14 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { Resend } from "resend";
|
||||
|
||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||
let resendClient: Resend | null = null;
|
||||
|
||||
type SendAppEmailInput = {
|
||||
to: string | string[];
|
||||
subject: string;
|
||||
react: ReactNode;
|
||||
from?: string;
|
||||
replyTo?: string | string[];
|
||||
};
|
||||
|
||||
type SendAppEmailResult =
|
||||
@@ -31,6 +32,7 @@ export async function sendAppEmail({
|
||||
subject,
|
||||
react,
|
||||
from = process.env.EMAIL_FROM,
|
||||
replyTo,
|
||||
}: SendAppEmailInput): Promise<SendAppEmailResult> {
|
||||
if (!process.env.RESEND_API_KEY) {
|
||||
return {
|
||||
@@ -47,11 +49,13 @@ export async function sendAppEmail({
|
||||
}
|
||||
|
||||
try {
|
||||
const { data, error } = await resend.emails.send({
|
||||
resendClient ??= new Resend(process.env.RESEND_API_KEY);
|
||||
const { data, error } = await resendClient.emails.send({
|
||||
from: from!,
|
||||
to,
|
||||
subject,
|
||||
react,
|
||||
replyTo,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user