@@ -20,37 +20,64 @@ const subscribeNewsletter = async (req, res) => {
20
20
const newSubscriber = new Newsletter ( { email } ) ;
21
21
await newSubscriber . save ( ) ;
22
22
23
- // Configure the transporter
23
+ Configure the transporter
24
24
const transporter = nodemailer . createTransport ( {
25
25
service : "gmail" ,
26
26
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 ,
29
29
} ,
30
30
} ) ;
31
-
31
+
32
32
const mailOptions = {
33
33
34
- to : email ,
34
+ to : email , // Send confirmation email to the subscriber's email
35
35
subject : "Thank you for Subscribing to Our Newsletter" ,
36
36
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;">
43
55
Explore More
44
56
</a>
45
- <p style="margin-top: 30px;">Best Regards,<br>BitBox Team</p>
46
57
</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
+ ] ,
48
73
} ;
49
74
50
75
// Send the confirmation email
51
76
await transporter . sendMail ( mailOptions ) ;
52
77
53
- res . status ( 200 ) . json ( { message : "Subscription successful, confirmation email sent" } ) ;
78
+ res
79
+ . status ( 200 )
80
+ . json ( { message : "Subscription successful, confirmation email sent" } ) ;
54
81
} catch ( error ) {
55
82
console . error ( "Error in subscribing to newsletter:" , error . message ) ;
56
83
res . status ( 500 ) . json ( { message : error . message } ) ;
0 commit comments