Update Utils/sendEmail.js
This commit is contained in:
parent
6d60198672
commit
642bc45b81
@ -19,39 +19,49 @@
|
||||
// });
|
||||
// };
|
||||
// export default sendEmail;
|
||||
|
||||
import { createTransport } from "nodemailer";
|
||||
|
||||
// 1. Hardcoded working configuration (from your successful test)
|
||||
const transporter = createTransport({
|
||||
host: "smtp-relay.brevo.com", // Hardcoded to ensure it works
|
||||
host: "smtp-relay.brevo.com",
|
||||
port: 587,
|
||||
secure: false, // Required for Brevo
|
||||
secure: false,
|
||||
auth: {
|
||||
user: "78ab42003@smtp-brevo.com", // Your exact working credentials
|
||||
user: "78ab42003@smtp-brevo.com",
|
||||
pass: "saTOdNcySftx2PXG"
|
||||
},
|
||||
tls: {
|
||||
rejectUnauthorized: false // Disable temporarily for testing
|
||||
ciphers: "SSLv3"
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const sendEmail = async (options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
transporter.sendMail({
|
||||
...options,
|
||||
from: options.from || `Cheminova <cheminova2004@gmail.com>` // Default sender
|
||||
from: options.from || "Cheminova <cheminova2004@gmail.com>"
|
||||
}, (error, info) => {
|
||||
if (error) {
|
||||
console.log('Email error:', error);
|
||||
reject(error);
|
||||
console.log("Email send failed:", error);
|
||||
reject(false); // Return false on error )
|
||||
} else {
|
||||
console.log('Email sent:', info.messageId);
|
||||
resolve(info);
|
||||
console.log("Email sent:", info.messageId);
|
||||
resolve(true); // Return true on success
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 3. Connection verification
|
||||
transporter.verify(function(error) {
|
||||
if (error) {
|
||||
console.error("SMTP Connection FAILED:", error);
|
||||
} else {
|
||||
console.log("SMTP Connection READY");
|
||||
}
|
||||
});
|
||||
|
||||
export default sendEmail;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user