MCPcopy Create free account
hub / github.com/Bitbox-Connect/Bitbox / sendMailToAdmin

Function sendMailToAdmin

server/sendMail.js:4–55  ·  view source on GitHub ↗
(userData)

Source from the content-addressed store, hash-verified

2require("dotenv").config();
3
4const sendMailToAdmin = (userData) => {
5 const transporter = nodemailer.createTransport({
6 service: "gmail",
7 host: "smtp.gmail.com",
8 port: 587,
9 secure: false, // Use `true` for port 465, `false` for other ports
10 auth: {
11 user: process.env.EMAIL_ID, // Your email address
12 pass: process.env.PASS_KEY, // Your email password or app-specific password
13 },
14 });
15
16
17 async function main() {
18 await transporter.sendMail({
19 from: {
20 name: `Bitbox Contact - ${new Date().toLocaleString()}`,
21 address: process.env.EMAIL_ID,
22 },
23 to: process.env.ADMIN_EMAIL_ID, // Admin email address
24 subject: "New Contact Form Submission from Bitbox ✔", // Email subject
25 text: "Bitbox Contact Form", // Plain text body
26 html: `<div style="background: #282c34; color: white; padding: 20px; font-family: Arial, sans-serif;">
27 <h2 style="text-align: center; color: #61dafb;">Bitbox Contact Form Details</h2>
28 <table style="width: 100%; max-width: 600px; margin: 20px auto; border-collapse: collapse;">
29 <tr>
30 <th style="padding: 10px; background-color: #0076b4; color: white; border: 1px solid #ddd;">Field</th>
31 <th style="padding: 10px; background-color: #0076b4; color: white; border: 1px solid #ddd;">Value</th>
32 </tr>
33 <tr>
34 <td style="padding: 10px; border: 1px solid #ddd;">Name</td>
35 <td style="padding: 10px; border: 1px solid #ddd;">${userData.name}</td>
36 </tr>
37 <tr>
38 <td style="padding: 10px; border: 1px solid #ddd;">Email</td>
39 <td style="padding: 10px; border: 1px solid #ddd;">${userData.email}</td>
40 </tr>
41 <tr>
42 <td style="padding: 10px; border: 1px solid #ddd;">Message</td>
43 <td style="padding: 10px; border: 1px solid #ddd;">${userData.msg}</td>
44 </tr>
45 <tr>
46 <td style="padding: 10px; border: 1px solid #ddd;">Submitted At</td>
47 <td style="padding: 10px; border: 1px solid #ddd;">${new Date(userData.createdAt).toLocaleString()}</td>
48 </tr>
49 </table>
50 </div>`, // HTML body content
51 });
52 }
53
54 main().catch(console.error);
55};
56
57module.exports = { sendMailToAdmin };

Callers 2

submitQueeryFunction · 0.50
submitFeedbackFunction · 0.50

Calls 1

mainFunction · 0.70

Tested by

no test coverage detected