Update Utils/sendEmail.js
This commit is contained in:
parent
9cb4d8310b
commit
cd86426605
@ -1,23 +1,56 @@
|
||||
import nodeMailer from "nodemailer";
|
||||
// import nodeMailer from "nodemailer";
|
||||
// import { createTransport } from "nodemailer";
|
||||
|
||||
// const transporter = createTransport({
|
||||
// host: process.env.SMPT_HOST,
|
||||
// port: process.env.SMPT_PORT,
|
||||
// // service: process.env.SMPT_SERVICE,
|
||||
// auth: {
|
||||
// user: process.env.SMPT_MAIL,
|
||||
// pass: process.env.SMPT_PASSWORD,
|
||||
// },
|
||||
// });
|
||||
|
||||
// const sendEmail = async (options) => {
|
||||
// await transporter.sendMail(options, function (error, info) {
|
||||
// if (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
// export default sendEmail;
|
||||
|
||||
import { createTransport } from "nodemailer";
|
||||
|
||||
// 1. Transport configuration (identical to your working version)
|
||||
const transporter = createTransport({
|
||||
host: process.env.SMPT_HOST,
|
||||
port: process.env.SMPT_PORT,
|
||||
// service: process.env.SMPT_SERVICE,
|
||||
host: "smtp-relay.brevo.com", // Directly using working host
|
||||
port: 587,
|
||||
secure: false, // Keep false for STARTTLS
|
||||
auth: {
|
||||
user: process.env.SMPT_MAIL,
|
||||
pass: process.env.SMPT_PASSWORD,
|
||||
user: "78ab42003@smtp-brevo.com", // Your working credentials
|
||||
pass: "saTOdNcySftx2PXG" // Your working password
|
||||
},
|
||||
// No special TLS settings to match original working version
|
||||
});
|
||||
|
||||
// 2. EXACT original function signature
|
||||
const sendEmail = async (options) => {
|
||||
await transporter.sendMail(options, function (error, info) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
}
|
||||
return new Promise((resolve) => { // Remove reject to match your original
|
||||
transporter.sendMail({
|
||||
...options,
|
||||
from: options.from || "Cheminova <cheminova2004@gmail.com>"
|
||||
}, (error, info) => {
|
||||
if (error) {
|
||||
console.log(error); // Same as original
|
||||
resolve(false); // Return false on error (original behavior)
|
||||
} else {
|
||||
resolve(true); // Return true on success (original behavior)
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default sendEmail;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user