Update Utils/sendEmail.js

This commit is contained in:
gitadmin 2025-04-29 03:50:01 +00:00
parent 82856035f8
commit 63f04f93d5

View File

@ -19,40 +19,30 @@
// }); // });
// }; // };
// export default sendEmail; // export default sendEmail;
import nodemailer from "nodemailer";
import { createTransport } from "nodemailer"; const transporter = nodemailer.createTransport({
const transporter = createTransport({
host: "smtp-relay.brevo.com", host: "smtp-relay.brevo.com",
port: 587, port: 587,
secure: false, // true for 465, false for other ports
auth: { auth: {
user: "78ab42003@smtp-brevo.com", user: "78ab42003@smtp-brevo.com",
pass: "saTOdNcySftx2PXG" pass: "saTOdNcySftx2PXG",
}, },
tls: {
rejectUnauthorized: false // Disable certificate validation for testing
}
}); });
const sendEmail = async (options) => { const sendEmail = async (options) => {
try { try {
await transporter.sendMail({ await transporter.sendMail(options);
from: options.from || "Cheminova <cheminova2004@gmail.com>", console.log("Email sent successfully");
to: options.to,
subject: options.subject,
html: options.html
});
return true;
} catch (error) { } catch (error) {
console.error('Email send error:', error); console.log(error);
return true; // Maintain your existing behavior of always returning true
} }
}; };
export default sendEmail; export default sendEmail;
// import sgMail from '@sendgrid/mail'; // import sgMail from '@sendgrid/mail';
// sgMail.setApiKey(process.env.SENDGRID_API_KEY) // sgMail.setApiKey(process.env.SENDGRID_API_KEY)
// // console.log(process.env.SENDGRID_API_KEY) // // console.log(process.env.SENDGRID_API_KEY)