Update Utils/sendEmail.js
This commit is contained in:
parent
82856035f8
commit
63f04f93d5
@ -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 <cheminova2004@gmail.com>",
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user