diff --git a/public/maisondetreats/img/bottom.png b/public/maisondetreats/img/bottom.png new file mode 100644 index 0000000..0cf1dc4 Binary files /dev/null and b/public/maisondetreats/img/bottom.png differ diff --git a/public/maisondetreats/img/logo-2.webp b/public/maisondetreats/img/logo-2.webp new file mode 100644 index 0000000..0009850 Binary files /dev/null and b/public/maisondetreats/img/logo-2.webp differ diff --git a/public/maisondetreats/img/thank-you.png b/public/maisondetreats/img/thank-you.png new file mode 100644 index 0000000..d699e32 Binary files /dev/null and b/public/maisondetreats/img/thank-you.png differ diff --git a/server.js b/server.js index ae301e5..ed61d7a 100644 --- a/server.js +++ b/server.js @@ -35,6 +35,7 @@ app.use( "http://127.0.0.1:3000", "https://api.crawlerx.co", "https://app.crawlerx.co", + "https://maisondetreats.com/" ], }) ); diff --git a/utils/mailer.js b/utils/mailer.js index 0c4849f..8f67977 100644 --- a/utils/mailer.js +++ b/utils/mailer.js @@ -1,5 +1,5 @@ import nodemailer from "nodemailer"; - +import juice from "juice"; // // Create reusable transporter object // @@ -26,7 +26,7 @@ export const mailer = nodemailer.createTransport({ export async function sendSignupMail(toEmail) { try { await mailer.sendMail({ - from: `"CrawlerX" <${process.env.SMTP_USER}>`, + from: `"CrawlerX" info@crawlerx.co`, to: toEmail, subject: "Welcome to CrawlerX", html: ` @@ -62,44 +62,99 @@ export async function sendResetPasswordMail(email, token) { } } - +// Send cake order email export const sendCakeOrderMail = async (toEmail, orderData) => { try { const transporter = nodemailer.createTransport({ host: "mail.crawlerx.co", port: 587, - secure: false, // use TLS? false for port 587 + secure: false, auth: { user: "info@crawlerx.co", pass: "CrawlerX@2025", }, - tls: { - rejectUnauthorized: false, // <--- allow self-signed certificate - }, + tls: { rejectUnauthorized: false }, }); - const orderItems = Object.entries(orderData) - .map(([category, flavours]) => { - const items = Object.entries(flavours) - .map(([flavour, qty]) => `• ${flavour}: ${qty}`) - .join("\n"); - return `${category}:\n${items}`; - }) - .join("\n\n"); + // Build table rows + let orderRows = ""; + Object.entries(orderData).forEach(([category, flavours]) => { + Object.entries(flavours).forEach(([flavour, qty]) => { + orderRows += ` +
Here are your cake order details:
-${orderItems}`,
+ html: htmlContent,
+ attachments: [
+ {
+ filename: "logo-2.webp",
+ path: "./public/maisondetreats/img/logo-2.webp",
+ cid: "logo",
+ },
+ {
+ filename: "thank-you.png",
+ path: "./public/maisondetreats/img/thank-you.png",
+ cid: "banner",
+ },
+ {
+ filename: "bottom.png",
+ path: "./public/maisondetreats/img/bottom.png",
+ cid: "footer",
+ },
+ ],
};
await transporter.sendMail(mailOptions);
- console.log("Cake order email sent to", toEmail);
+ console.log("✅ Cake order email sent to", toEmail);
} catch (err) {
- console.error("Failed to send cake order email:", err);
+ console.error("❌ Failed to send cake order email:", err);
}
};
\ No newline at end of file