Email Sender
IntegrationsSend transactional emails via your preferred provider. Supports templates and attachments.
// email-sender.ts
import { defineHandler } from '@fold-run/runtime'
export default defineHandler(async (fold) => {
const { to, subject, body } = await fold.body<{ to: string; subject: string; body: string }>();
const apiKey = fold.secret("RESEND_API_KEY");
const response = await fetch("https://api.resend.com/emails", {
method: "POST",
headers: { "Authorization": `Bearer ${apiKey}` },
body: JSON.stringify({ from: "noreply@example.com", to, subject, html: body }),
});
return fold.json({ sent: response.ok });
});