-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (32 loc) · 963 Bytes
/
server.js
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
// server.js
const express = require('express');
const nodemailer = require('nodemailer');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.post('/send-email', (req, res) => {
const { email, message } = req.body;
// Configure your email transport
const transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'your-email@gmail.com',
pass: 'your-email-password'
}
});
const mailOptions = {
from: email,
to: 'imaansoltan@gmail.com',
subject: 'Contact Form Submission',
text: message
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return res.status(500).send(error.toString());
}
res.status(200).send('Email sent: ' + info.response);
});
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});