diff --git a/.env.development b/.env.development index 7fa257d..d175e5d 100644 --- a/.env.development +++ b/.env.development @@ -37,6 +37,3 @@ DB_PORT=3306 SMTP_HOST=autodiscover.qcells.com SMTP_PORT=25 SMTP_SECURE=false -SMTP_USER=hss404.u021@cleverse.dev -SMTP_PASSWORD=0000 -SMTP_FROM=qsalesplatform@qcells.com \ No newline at end of file diff --git a/.env.localhost b/.env.localhost index e7e54cd..68be6be 100644 --- a/.env.localhost +++ b/.env.localhost @@ -32,6 +32,3 @@ DB_PORT=3306 SMTP_HOST=autodiscover.qcells.com SMTP_PORT=25 SMTP_SECURE=false -SMTP_USER=hss404.u021@cleverse.dev -SMTP_PASSWORD=0000 -SMTP_FROM=qsalesplatform@qcells.com diff --git a/.env.production b/.env.production index efb8936..3b8b24c 100644 --- a/.env.production +++ b/.env.production @@ -30,6 +30,3 @@ DB_PORT=3306 SMTP_HOST=autodiscover.qcells.com SMTP_PORT=25 SMTP_SECURE=true -SMTP_USER=hss404.u021@cleverse.dev -SMTP_PASSWORD=0000 -SMTP_FROM=qsalesplatform@qcells.com \ No newline at end of file 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 0636df2..1b646c2 100644 --- a/src/libs/mailer.ts +++ b/src/libs/mailer.ts @@ -3,28 +3,26 @@ 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, port: Number(process.env.SMTP_PORT), secure: process.env.SMTP_SECURE === 'true', requireTLS: true, - auth: { - user: process.env.SMTP_USER, - pass: process.env.SMTP_PASSWORD, - }, + tls: { rejectUnauthorized: false }, }) // 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, @@ -42,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',