From 63f04f93d5cb3915d76eb807da485e386fe1e401 Mon Sep 17 00:00:00 2001 From: gitadmin Date: Tue, 29 Apr 2025 03:50:01 +0000 Subject: [PATCH] Update Utils/sendEmail.js --- Utils/sendEmail.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/Utils/sendEmail.js b/Utils/sendEmail.js index b21b03e..864bfda 100644 --- a/Utils/sendEmail.js +++ b/Utils/sendEmail.js @@ -19,40 +19,30 @@ // }); // }; // export default sendEmail; +import nodemailer from "nodemailer"; -import { createTransport } from "nodemailer"; - -const transporter = createTransport({ +const transporter = nodemailer.createTransport({ host: "smtp-relay.brevo.com", port: 587, - secure: false, // true for 465, false for other ports auth: { user: "78ab42003@smtp-brevo.com", - pass: "saTOdNcySftx2PXG" + pass: "saTOdNcySftx2PXG", }, - tls: { - rejectUnauthorized: false // Disable certificate validation for testing - } }); const sendEmail = async (options) => { try { - await transporter.sendMail({ - from: options.from || "Cheminova ", - to: options.to, - subject: options.subject, - html: options.html - }); - return true; + await transporter.sendMail(options); + console.log("Email sent successfully"); } catch (error) { - console.error('Email send error:', error); - return true; // Maintain your existing behavior of always returning true + console.log(error); } }; export default sendEmail; + // import sgMail from '@sendgrid/mail'; // sgMail.setApiKey(process.env.SENDGRID_API_KEY) // // console.log(process.env.SENDGRID_API_KEY)