-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
50 lines (43 loc) · 1.57 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
let express = require("express"),
path = require('path'),
nodeMailer = require('nodemailer'),
multer = require('multer'),
bodyParser = require('body-parser');
var upload = multer();
let app = express();
app.use(express.static('public/thank-you/dist/'));
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(upload.array());
app.post('/myaction', function (req, res) {
let transporter = nodeMailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
// should be replaced with real sender's account
user: 'srikanth.jallapuram@gmail.com',
pass: 'Accel@$123'
}
});
let mailOptions = {
// should be replaced with real recipient's account
to: 'srikanthjnr@yahoo.com',
subject:'Form Submission: Technovature Software Contact Form',
phone: req.body.phonenum,
text: req.body.briefdesc,
html: `First Name: ${req.body.firstname} <br> Last Name: ${req.body.lastname} <br> Brief Description: ${req.body.briefdescription} <br> Phonenumber: ${req.body.phonenum} <br> Email: ${req.body.email}`
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
res.writeHead(301, { Location: 'index.html' });
res.end(JSON.stringify(req.body, null, 2));
});
let server = app.listen(8081, function(){
let port = server.address().port;
console.log("Server started at http://localhost:%s", port);
});