Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
shivenyadavs authored Nov 9, 2024
2 parents d0b5121 + d3eca41 commit 6a7eaa2
Show file tree
Hide file tree
Showing 8 changed files with 629 additions and 1,288 deletions.
70 changes: 70 additions & 0 deletions backend/controllers/ContactController.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,73 @@ exports.suggestion = async (req, resp) => {
});
}
};

exports.newsletter = async (req, resp) => {
try {
const { email } = req.body;

if (!email) {
return resp.status(400).json({ message: "Email is required" });
}

// Configure the transporter with your email credentials
const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
},
});

const mailOptions = {
from: process.env.EMAIL_USER,
to: email,
subject: "Thank you for Subscribing to BuddyTrail",
html: `
<div style="font-family: Arial, sans-serif; color: #333; max-width: 600px; margin: 0 auto; border: 1px solid #e0e0e0; border-radius: 8px;">
<!-- Header -->
<div style="background:#000000; padding: 20px; text-align: center; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom: 1px solid #e0e0e0;">
<img src="cid:headerImage" alt="BuddyTrail Logo" style="width: 100px; margin-bottom: 10px;">
<h1 style="color:#e3e3e3; margin: 0;">Welcome to Our Newsletter</h1>
</div>
<!-- Body Content -->
<div style="padding: 20px; text-align: center;">
<h2 style="color: #007BFF;">Thank You for Subscribing!</h2>
<p>Dear Subscriber,</p>
<p>We are thrilled to have you with us. Stay tuned for our latest updates, offers, and insights to keep you informed and inspired!</p>
<!-- Button -->
<div style="margin-top: 20px;">
<a href="https://buddytrail.netlify.app/"
style="display: inline-block; padding: 12px 25px; background-color: #007BFF; color: white; font-size: 16px; font-weight: bold; text-decoration: none; border-radius: 5px;">
Discover More
</a>
</div>
</div>
<!-- Footer -->
<div style="background-color: #f5f5f5; padding: 15px; text-align: center; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<p style="font-size: 14px; color: #666;">Best Regards,<br><strong>BuddyTrail Team</strong></p>
<p style="font-size: 12px; color: #999;">&copy; ${new Date().getFullYear()} BuddyTrail. All rights reserved.</p>
</div>
</div>
`,
attachments: [
{
filename: "buddytrail-logo.png",
path: "C:/Users/ayush/OneDrive/Desktop/BuddyTrail/backend/controllers/image.png",
cid: "headerImage",
},
],
};

// Send the email
await transporter.sendMail(mailOptions);

resp.status(200).json({ message: "Newsletter email sent successfully!" });
} catch (error) {
console.error("Error sending newsletter:", error);
resp.status(500).json({ message: "Error sending newsletter" });
}
};
Binary file added backend/controllers/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions backend/routes/ContactRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
userfeedback,

sendEmail,
newsletter,
suggestion,
} = require("../controllers/ContactController.js");

Expand All @@ -18,4 +19,5 @@ router.post("/email", sendEmail);

router.post("/suggestion", suggestion);

router.post("/newsletter", newsletter);
module.exports = router;
Loading

0 comments on commit 6a7eaa2

Please sign in to comment.