Files
newsletter-hackernews/utils/sender.ts
2023-12-04 16:18:35 +01:00

25 lines
435 B
TypeScript

import { Resend } from 'resend';
export async function sendEmail(
to: string[],
subject: string,
template: JSX.Element
) {
const resend = new Resend(process.env.RESEND_KEY);
try {
const { error } = await resend.emails.send({
from: process.env.RESEND_FROM!,
to,
subject,
react: template,
});
if (error) {
console.log(error);
}
} catch (error) {
console.log(error);
}
}