-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeedbackHandler.js
More file actions
72 lines (61 loc) · 2.84 KB
/
feedbackHandler.js
File metadata and controls
72 lines (61 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// feedbackHandler.js
const nodemailer = require("nodemailer");
function getFeedbackTypeLabel(type) {
const map = {
feedback: '💭 General Feedback',
feature_request: '🚀 Feature Request',
feature_like: '❤️ I Like a Feature'
};
return map[type] || type;
}
async function sendFeedbackEmail(data) {
const transporter = nodemailer.createTransport({
service: "hotmail", // or "hotmail"
auth: {
user: "YOUR_MAIL@MAIL.COM", // your email
pass: "PASSWORD" // replace with secure credentials
}
});
const htmlContent = `
<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 600px; margin: 0 auto;">
<div style="background: linear-gradient(135deg, #667eea, #764ba2); padding: 30px; border-radius: 12px; color: white; text-align: center; margin-bottom: 20px;">
<h1 style="margin: 0; font-size: 24px;">💬 New Feedback Received</h1>
</div>
<div style="background: #f8f9ff; padding: 30px; border-radius: 12px; border: 1px solid #e1e5f7;">
<div style="margin-bottom: 20px;">
<strong style="color: #667eea;">📧 Email:</strong>
<span style="margin-left: 10px;">${data.email}</span>
</div>
<div style="margin-bottom: 20px;">
<strong style="color: #667eea;">↩️ Reply Requested:</strong>
<span style="margin-left: 10px;">${data.replyBack === 'true' ? '✅ Yes' : '❌ No'}</span>
</div>
<div style="margin-bottom: 20px;">
<strong style="color: #667eea;">📝 Topic:</strong>
<span style="margin-left: 10px;">${data.topic}</span>
</div>
<div style="margin-bottom: 20px;">
<strong style="color: #667eea;">🏷️ Type:</strong>
<span style="margin-left: 10px; padding: 4px 12px; background: #667eea; color: white; border-radius: 20px; font-size: 12px;">
${getFeedbackTypeLabel(data.feedbackType)}
</span>
</div>
<div style="margin-bottom: 20px;">
<strong style="color: #667eea;">💬 Description:</strong>
<div style="margin-top: 10px; padding: 15px; background: white; border-radius: 8px; border-left: 4px solid #667eea;">
${data.description}
</div>
</div>
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #e1e5f7; color: #666; font-size: 12px;">
<strong>Submitted:</strong> ${new Date(data.timestamp).toLocaleString()}
</div>
</div>
</div>`;
await transporter.sendMail({
from: '"Feedback Bot" <YOUR_MAIL>',
to: "YOUR_MAIL",
subject: "📩 New Feedback Received",
html: htmlContent
});
}
module.exports = { sendFeedbackEmail };