maisondetreats diwali hampers form order mailer template updated
This commit is contained in:
parent
6c345df1c2
commit
6549e50b87
BIN
public/maisondetreats/img/bottom.png
Normal file
BIN
public/maisondetreats/img/bottom.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
BIN
public/maisondetreats/img/logo-2.webp
Normal file
BIN
public/maisondetreats/img/logo-2.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/maisondetreats/img/thank-you.png
Normal file
BIN
public/maisondetreats/img/thank-you.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 613 KiB |
@ -35,6 +35,7 @@ app.use(
|
|||||||
"http://127.0.0.1:3000",
|
"http://127.0.0.1:3000",
|
||||||
"https://api.crawlerx.co",
|
"https://api.crawlerx.co",
|
||||||
"https://app.crawlerx.co",
|
"https://app.crawlerx.co",
|
||||||
|
"https://maisondetreats.com/"
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import nodemailer from "nodemailer";
|
import nodemailer from "nodemailer";
|
||||||
|
import juice from "juice";
|
||||||
//
|
//
|
||||||
// Create reusable transporter object
|
// Create reusable transporter object
|
||||||
//
|
//
|
||||||
@ -26,7 +26,7 @@ export const mailer = nodemailer.createTransport({
|
|||||||
export async function sendSignupMail(toEmail) {
|
export async function sendSignupMail(toEmail) {
|
||||||
try {
|
try {
|
||||||
await mailer.sendMail({
|
await mailer.sendMail({
|
||||||
from: `"CrawlerX" <${process.env.SMTP_USER}>`,
|
from: `"CrawlerX" info@crawlerx.co`,
|
||||||
to: toEmail,
|
to: toEmail,
|
||||||
subject: "Welcome to CrawlerX",
|
subject: "Welcome to CrawlerX",
|
||||||
html: `
|
html: `
|
||||||
@ -62,44 +62,99 @@ export async function sendResetPasswordMail(email, token) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send cake order email
|
||||||
export const sendCakeOrderMail = async (toEmail, orderData) => {
|
export const sendCakeOrderMail = async (toEmail, orderData) => {
|
||||||
try {
|
try {
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
host: "mail.crawlerx.co",
|
host: "mail.crawlerx.co",
|
||||||
port: 587,
|
port: 587,
|
||||||
secure: false, // use TLS? false for port 587
|
secure: false,
|
||||||
auth: {
|
auth: {
|
||||||
user: "info@crawlerx.co",
|
user: "info@crawlerx.co",
|
||||||
pass: "CrawlerX@2025",
|
pass: "CrawlerX@2025",
|
||||||
},
|
},
|
||||||
tls: {
|
tls: { rejectUnauthorized: false },
|
||||||
rejectUnauthorized: false, // <--- allow self-signed certificate
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const orderItems = Object.entries(orderData)
|
// Build table rows
|
||||||
.map(([category, flavours]) => {
|
let orderRows = "";
|
||||||
const items = Object.entries(flavours)
|
Object.entries(orderData).forEach(([category, flavours]) => {
|
||||||
.map(([flavour, qty]) => `• ${flavour}: ${qty}`)
|
Object.entries(flavours).forEach(([flavour, qty]) => {
|
||||||
.join("\n");
|
orderRows += `
|
||||||
return `${category}:\n${items}`;
|
<tr>
|
||||||
})
|
<td style="padding:10px 12px;">${category}</td>
|
||||||
.join("\n\n");
|
<td style="padding:10px 12px;">${flavour}</td>
|
||||||
|
<td style="padding:10px 12px;">${qty}</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// HTML content with local images via cid
|
||||||
|
const htmlContent = `
|
||||||
|
<div style="max-width:750px;margin:30px auto;background-color:#fff;border-radius:20px;overflow:hidden;font-family:'Segoe UI',Tahoma,sans-serif;color:#333;">
|
||||||
|
<table width="100%" cellpadding="0" cellspacing="0" style="background-color:#faf4f0;padding:15px 25px;">
|
||||||
|
<tr>
|
||||||
|
<td align="left">
|
||||||
|
<img src="cid:logo" width="150" style="display:block;" />
|
||||||
|
</td>
|
||||||
|
<td align="right" style="font-size:14px;color:#d72631;font-weight:600;">
|
||||||
|
Order Date: ${new Date().toLocaleString()}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<div style="text-align:center;padding:30px 0;">
|
||||||
|
<img src="cid:banner" style="width:100%;max-height:300px;object-fit:cover;border-radius:0 0 20px 20px;"/>
|
||||||
|
</div>
|
||||||
|
<div style="padding:15px 25px;text-align:center;">
|
||||||
|
<h2 style="color:rgb(255 135 174);font-family:'Brush Script MT',cursive;font-size:22px;margin-bottom:12px;font-weight:700;">Order Details</h2>
|
||||||
|
<table style="width:100%;border-collapse:collapse;font-size:14px;margin:0 auto 15px;">
|
||||||
|
<thead>
|
||||||
|
<tr style="background-color:#faf4f0;color:#d72631;font-weight:600;">
|
||||||
|
<th style="padding:10px 12px;text-align:left;">Treats</th>
|
||||||
|
<th style="padding:10px 12px;text-align:left;">Flavour</th>
|
||||||
|
<th style="padding:10px 12px;text-align:left;">Quantity</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${orderRows}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<a href="https://maisondetreats.com/" style="display:inline-block;background-color:#d72631;color:#fff;padding:10px 25px;border-radius:30px;text-decoration:none;font-weight:bold;margin-top:15px;">Visit Our Website</a>
|
||||||
|
</div>
|
||||||
|
<div style="text-align:center;padding:30px 0;background-color:#d72631;color:#fff;">
|
||||||
|
<img src="cid:footer" style="width:100%;max-height:100px;object-fit:cover;"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
const mailOptions = {
|
const mailOptions = {
|
||||||
from: `"Maison de Treats" <info@crawlerx.co>`,
|
from: '"Maison de Treats" <info@crawlerx.co>',
|
||||||
to: toEmail,
|
to: toEmail,
|
||||||
subject: "🎉 Your Cake Order Confirmation",
|
subject: "🎉 Your Cake Order Confirmation",
|
||||||
text: `Thank you for your order! Here are the details:\n\n${orderItems}`,
|
html: htmlContent,
|
||||||
html: `<h2>Thank you for your order!</h2>
|
attachments: [
|
||||||
<p>Here are your cake order details:</p>
|
{
|
||||||
<pre>${orderItems}</pre>`,
|
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);
|
await transporter.sendMail(mailOptions);
|
||||||
console.log("Cake order email sent to", toEmail);
|
console.log("✅ Cake order email sent to", toEmail);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to send cake order email:", err);
|
console.error("❌ Failed to send cake order email:", err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user