-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
executable file
·34 lines (29 loc) · 944 Bytes
/
script.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
const nodemailer = require('nodemailer');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/send-email', (req, res) => {
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'your-email-password'
}
});
let mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Product Interest',
text: 'Someone clicked the Buy button for the product!'
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return res.status(500).send('Error sending email');
}
res.status(200).send('Email sent: ' + info.response);
});
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});