diff --git a/src/components/popup/SurveySaleSubmitPopup.tsx b/src/components/popup/SurveySaleSubmitPopup.tsx index 0fe861e..2a0e696 100644 --- a/src/components/popup/SurveySaleSubmitPopup.tsx +++ b/src/components/popup/SurveySaleSubmitPopup.tsx @@ -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, diff --git a/src/libs/mailer.ts b/src/libs/mailer.ts index da62cc3..1b646c2 100644 --- a/src/libs/mailer.ts +++ b/src/libs/mailer.ts @@ -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 { +export async function sendEmail({ from, to, cc, subject, content }: EmailParams): Promise { // 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',