/** * 이메일 발송 서비스 (Resend API) * 인증 이메일 발송 */ import { Resend } from "resend"; const RESEND_API_KEY = process.env.RESEND_API_KEY; const MAIL_FROM = process.env.MAIL_FROM || "no-reply@caadiq.co.kr"; const SITE_URL = process.env.SITE_URL || "https://minecraft.caadiq.co.kr"; // Resend 클라이언트 생성 const resend = new Resend(RESEND_API_KEY); /** * 이메일 인증 메일 발송 */ export async function sendVerificationEmail(to, token, name) { const verifyUrl = `${SITE_URL}/verify/${token}`; const html = `

이메일 인증

안녕하세요${name ? `, ${name}님` : ""}!

마인크래프트 서버 대시보드에 가입해주셔서 감사합니다.
아래 버튼을 클릭하여 이메일 인증을 완료해주세요.

이메일 인증하기

버튼이 작동하지 않으면 아래 링크를 복사해서 브라우저에 붙여넣으세요:

`; try { const result = await resend.emails.send({ from: MAIL_FROM, to: to, subject: "[마인크래프트 서버] 이메일 인증", html: html, }); if (result.error) { console.error("[Email] 발송 오류:", result.error); throw new Error(result.error.message); } console.log(`[Email] 인증 메일 발송 완료: ${to}`); return { success: true, messageId: result.data?.id }; } catch (error) { console.error("[Email] 발송 실패:", error); throw error; } } export default { sendVerificationEmail };