Skip to content

Commit 395c702

Browse files
authored
Merge pull request #387 from AyushSharma72/newsletter
added news letter api @387
2 parents 59698e6 + 052495e commit 395c702

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

server/Controllers/OtherController.js

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,64 @@ const subscribeNewsletter = async (req, res) => {
2020
const newSubscriber = new Newsletter({ email });
2121
await newSubscriber.save();
2222

23-
// Configure the transporter
23+
Configure the transporter
2424
const transporter = nodemailer.createTransport({
2525
service: "gmail",
2626
auth: {
27-
user: process.env.EMAIL_USER, // Your email
28-
pass: process.env.EMAIL_PASS, // Your email password (use environment variables in production)
27+
user: process.env.EMAIL_USER, // Use environment variables in production
28+
pass: process.env.EMAIL_PASS,
2929
},
3030
});
31-
31+
3232
const mailOptions = {
3333
34-
to: email,
34+
to: email, // Send confirmation email to the subscriber's email
3535
subject: "Thank you for Subscribing to Our Newsletter",
3636
html: `
37-
<div style="font-family: Arial, sans-serif; text-align: center;">
38-
<h2>Thank You for Subscribing!</h2>
39-
<p>Dear Subscriber,</p>
40-
<p>We are thrilled to have you with us. Stay tuned for our latest updates and offers!</p>
41-
<a href="https://bitbox-in.netlify.app/"
42-
style="display: inline-block; padding: 10px 20px; margin-top: 20px; color: white; background-color: #007BFF; text-decoration: none; border-radius: 5px;">
37+
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: auto; border: 1px solid #ddd; border-radius: 8px; overflow: hidden;">
38+
<!-- Header -->
39+
<div style="background-color: #4A90E2; padding: 20px; text-align: center; color: white;">
40+
<img src="cid:welcomeImage" alt="Welcome" style="width: 120px; margin-bottom: 10px;" />
41+
<h1 style="font-size: 24px; margin: 0;">Thank You for Subscribing!</h1>
42+
</div>
43+
44+
<!-- Body -->
45+
<div style="padding: 30px; background-color: #f8f8f8; text-align: center;">
46+
<h2 style="color: #333; font-size: 20px; margin-bottom: 15px;">Welcome to the BitBox Community!</h2>
47+
<p style="font-size: 16px; color: #555; line-height: 1.6; margin: 0 0 20px;">
48+
Dear Subscriber,
49+
</p>
50+
<p style="font-size: 16px; color: #555; line-height: 1.6; margin: 0 0 20px;">
51+
We’re thrilled to have you with us. Get ready to stay updated with the latest trends and offers.
52+
</p>
53+
54+
<a href="https://bitbox-in.netlify.app/" style="display: inline-block; padding: 12px 25px; margin-top: 20px; background-color: #4A90E2; color: white; font-size: 16px; font-weight: bold; text-decoration: none; border-radius: 5px;">
4355
Explore More
4456
</a>
45-
<p style="margin-top: 30px;">Best Regards,<br>BitBox Team</p>
4657
</div>
47-
`,
58+
59+
<!-- Footer -->
60+
<div style="background-color: #333; color: white; padding: 20px; text-align: center;">
61+
<p style="margin: 0; font-size: 14px;">Best Regards, <br> <strong>BitBox Team</strong></p>
62+
<p style="margin: 0; font-size: 12px; color: #ccc;">Follow us on our social channels for more updates</p>
63+
</div>
64+
</div>
65+
`,
66+
attachments: [
67+
{
68+
filename: "bitbox",
69+
path: "Controllers/assests/bitboximage.png",
70+
cid: "welcomeImage",
71+
},
72+
],
4873
};
4974

5075
// Send the confirmation email
5176
await transporter.sendMail(mailOptions);
5277

53-
res.status(200).json({ message: "Subscription successful, confirmation email sent" });
78+
res
79+
.status(200)
80+
.json({ message: "Subscription successful, confirmation email sent" });
5481
} catch (error) {
5582
console.error("Error in subscribing to newsletter:", error.message);
5683
res.status(500).json({ message: error.message });
53.1 KB
Loading

0 commit comments

Comments
 (0)