Files
jaengseung-made/app/api/contact/route.ts
gahusb 8255ecab0c Fix Resend email sender address
- from 필드를 onboarding@resend.dev로 변경 (Resend 기본 도메인)
- reply_to 필드 추가 (문의자 이메일로 답장 가능)
- 커스텀 도메인 인증 없이 바로 사용 가능

테스트 완료: 이메일 발송 정상 작동 확인

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 02:16:03 +09:00

54 lines
1.8 KiB
TypeScript

import { NextResponse } from 'next/server';
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
export async function POST(request: Request) {
try {
const body = await request.json();
const { name, phone, email, service, message } = body;
// 입력 검증
if (!name || !email || !message) {
return NextResponse.json(
{ error: '필수 항목을 모두 입력해주세요.' },
{ status: 400 }
);
}
// 이메일 발송
const data = await resend.emails.send({
from: 'onboarding@resend.dev', // Resend 기본 도메인
to: ['bgg8988@gmail.com'], // 받는 이메일
reply_to: email, // 문의자 이메일로 답장 가능
subject: `[쟁승메이드] 새로운 문의: ${service || '문의'}`,
html: `
<h2>새로운 프로젝트 문의가 도착했습니다</h2>
<hr />
<p><strong>이름:</strong> ${name}</p>
<p><strong>연락처:</strong> ${phone || '미입력'}</p>
<p><strong>이메일:</strong> ${email}</p>
<p><strong>서비스:</strong> ${service || '미선택'}</p>
<hr />
<h3>문의 내용:</h3>
<p style="white-space: pre-wrap;">${message}</p>
<hr />
<p style="color: #666; font-size: 12px;">
이 메일은 jaengseung-made.com의 문의 폼에서 발송되었습니다.
</p>
`,
});
return NextResponse.json(
{ success: true, message: '문의가 성공적으로 전송되었습니다!' },
{ status: 200 }
);
} catch (error) {
console.error('Email send error:', error);
return NextResponse.json(
{ error: '메일 전송에 실패했습니다. 다시 시도해주세요.' },
{ status: 500 }
);
}
}