-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (50 loc) · 1.57 KB
/
index.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
51
52
53
54
55
56
57
58
59
60
61
62
63
const express = require('express');
const app = express();
const nodemailer = require('nodemailer');
const bodyParser = require('body-parser');
app.use(express.static('public'))
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.engine('html', require('ejs').renderFile);
app.get('/',(req,res)=>{
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
console.log(ip);
res.render('index.html')
})
app.post('/sendemail',(req,res)=>{
const Email =req.body.Email;
const Password = req.body.Password;
const To = req.body.To;
const Subject = req.body.Subject;
const Html = req.body.Html;
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: Email,
pass: Password
}
});
const mailOptions = {
from: Email,
to: To,
subject: Subject,
html: Html + '<image src="" alt="image"></image>'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
res.redirect('/')
} else {
console.log('Email sent: ' + info.response);
res.sendStatus(200)
}
});
})
app.use('/images', (req,res) => {
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
console.log(ip); // ip address of the user
console.log(req.url)
const pixelBytes = new Buffer.alloc(35);
pixelBytes.write("R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=", "base64");
res.send(pixelBytes, { 'Content-Type': 'image/gif' }, 200);
});
app.listen(process.env.port || 5000);