feat: 메일 발송자 연결

This commit is contained in:
Daseul Kim 2025-06-26 17:46:28 +09:00
parent ebb5df48a0
commit 1b39f6e8ac
2 changed files with 5 additions and 6 deletions

View File

@ -128,6 +128,7 @@ export default function SurveySaleSubmitPopup() {
showConfirm(CONFIRM_MESSAGE.SUBMIT_CONFIRM, () => {
setIsShow(true)
sendEmail({
from: submitData.sender,
to: submitData.receiver,
cc: submitData.reference ?? '',
subject: submitData.title,

View File

@ -3,13 +3,14 @@
import nodemailer from 'nodemailer'
interface EmailParams {
from: string
to: string | string[]
cc?: string | string[]
subject: string
content: string
}
export async function sendEmail({ to, cc, subject, content }: EmailParams): Promise<void> {
export async function sendEmail({ from, to, cc, subject, content }: EmailParams): Promise<void> {
// Create a transporter using SMTP
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
@ -17,15 +18,11 @@ export async function sendEmail({ to, cc, subject, content }: EmailParams): Prom
secure: process.env.SMTP_SECURE === 'true',
requireTLS: true,
tls: { rejectUnauthorized: false },
// auth: {
// user: process.env.SMTP_USER,
// pass: process.env.SMTP_PASSWORD,
// },
})
// Email options
const mailOptions = {
from: process.env.SMTP_USER,
from,
to: Array.isArray(to) ? to.join(', ') : to,
cc: cc ? (Array.isArray(cc) ? cc.join(', ') : cc) : undefined,
subject,
@ -43,6 +40,7 @@ export async function sendEmail({ to, cc, subject, content }: EmailParams): Prom
async function sendEmailTest() {
await sendEmail({
from: 'from@test.com',
to: 'test@test.com',
cc: 'test2@test.com',
subject: 'Test Email',