-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
50 lines (43 loc) · 1.35 KB
/
app.js
File metadata and controls
50 lines (43 loc) · 1.35 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
var http=require('http');
var express=require('express');
var nodemailer = require("nodemailer");
var bodyParser = require('body-parser')
var app=express();
var port = Number(process.env.PORT || 5000);
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({
extended: true
}));
// Home page
app.get('/',function(req,res){
res.sendfile('index.html');
});
// sending mail function
app.post('/send', function(req, res){
if(req.body.email == "" || req.body.subject == "") {
res.send("Error: Email & Subject should not blank");
return false;
}
// Sending Email Without SMTP
nodemailer.mail({
from: req.body.email1, // sender address
to: req.body.email2, // list of receivers
subject: req.body.subject+" ✔", // Subject line
//text: "Hello world ✔", // plaintext body
html: "<b>"+req.body.description+"</b>" // html body
});
res.send("Email has been sent successfully");
});
// Starting server
var server = http.createServer(app).listen(port, function() {
console.log("Listening on " + port);
});
var server2 = http.createServer(app).listen(port, function() {
console.log("Listening on " + port);
});
var server3 = http.createServer(app).listen(port, function() {
console.log("Listening on " + port);
});
var server4 = http.createServer(app).listen(port, function() {
console.log("Listening on " + port);
});