-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
110 lines (90 loc) · 3.2 KB
/
Copy pathserver.js
File metadata and controls
110 lines (90 loc) · 3.2 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// import express from "express";
// import nodemailer from "nodemailer";
// import cors from "cors";
// const app = express();
// app.use(express.json());
// app.use(cors());
// const transporter = nodemailer.createTransport({
// service: "gmail",
// auth: {
// user: "harittechsolution@gmail.com",
// pass: "jdjtmpcfjbpomodf"
// }
// });
// app.post("/contact", async (req, res) => {
// try {
// const { name, email, phone, service, message } = req.body;
// // Validate
// if (!name || !email || !phone || !service || !message) {
// return res.status(400).json({
// success: false,
// message: "All fields are required"
// });
// }
// await transporter.sendMail({
// from: `"HarIT Contact" <harittechsolution@gmail.com>`,
// to: "harittechsolution@gmail.com",
// subject: `New Contact Message from ${name}`,
// html: `
// <h2>New Contact Inquiry</h2>
// <p><strong>Name:</strong> ${name}</p>
// <p><strong>Email:</strong> ${email}</p>
// <p><strong>Phone:</strong> ${phone}</p>
// <p><strong>Service:</strong> ${service}</p>
// <p><strong>Message:</strong></p>
// <p>${message}</p>
// `
// });
// res.json({
// success: true,
// message: "Message sent successfully"
// });
// } catch (error) {
// console.log(error);
// res.status(500).json({
// success: false,
// message: "Failed to send message",
// error: error.message
// });
// }
// });
// app.listen(3000, () => console.log("Server running on port 3000"));
// import nodemailer from "nodemailer";
// export async function sendContactMail({ name, email, phone, service, message }) {
// try {
// // Validate fields
// if (!name || !email || !phone || !service || !message) {
// return { success: false, message: "All fields are required" };
// }
// // Mail transporter
// const transporter = nodemailer.createTransport({
// service: "gmail",
// auth: {
// user: "harittechsolution@gmail.com",
// pass: "jdjtmpcfjbpomodf"
// }
// });
// // Send email
// await transporter.sendMail({
// from: `"HarIT Contact" <harittechsolution@gmail.com>`,
// to: "harittechsolution@gmail.com",
// subject: `New Contact Message from ${name}`,
// html: `
// <h2>New Contact Inquiry</h2>
// <p><strong>Name:</strong> ${name}</p>
// <p><strong>Email:</strong> ${email}</p>
// <p><strong>Phone:</strong> ${phone}</p>
// <p><strong>Service:</strong> ${service}</p>
// <p><strong>Message:</strong></p>
// <p>${message}</p>
// `
// });
// return { success: true, message: "Message sent successfully" };
// } catch (error) {
// return {
// success: false,
// message: "Failed to send message",
// error: error.message
// };
// }
// }