import { env } from '../config.js' const RESEND_API_URL = 'https://api.resend.com/emails' function getFromAddress() { return `${env.MAIL_FROM_NAME} <${env.MAIL_FROM_EMAIL}>` } async function sendWithResend({ to, subject, html, text }) { if (!env.RESEND_API_KEY) { return { skipped: true, reason: 'RESEND_API_KEY is not configured.', } } const response = await fetch(RESEND_API_URL, { method: 'POST', headers: { Authorization: `Bearer ${env.RESEND_API_KEY}`, 'Content-Type': 'application/json', 'User-Agent': 'ten-minute-planner/1.0', }, body: JSON.stringify({ from: getFromAddress(), to, subject, html, text, }), }) const data = await response.json().catch(() => ({})) if (!response.ok) { throw new Error(data.message || data.error?.message || 'Resend 메일 발송에 실패했습니다.') } return { skipped: false, id: data.id, } } function buildLinkHtml({ title, description, linkUrl, buttonLabel }) { return `
10 Minute Planner
${description}
버튼이 열리지 않으면 아래 링크를 복사해서 브라우저에 붙여넣어 주세요.
${linkUrl}
이 링크는 30분 동안 사용할 수 있습니다.