zkmlab05 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of zkmlab05 might be problematic. Click here for more details.
- package/05_02.html +35 -0
- package/05_02.js +59 -0
- package/05_03.js +8 -0
- package/05_04.js +9 -0
- package/m06_ZKM.js +34 -0
- package/package.json +28 -0
package/05_02.html
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<div id="container">
|
8
|
+
<form action="http://localhost:5000/" method="POST">
|
9
|
+
<table id="container_table">
|
10
|
+
<tr>
|
11
|
+
<td>Отправитель</td>
|
12
|
+
<td><input id="sender" type="email" name="sender" placeholder="Ваш e-mail"></td>
|
13
|
+
</tr>
|
14
|
+
|
15
|
+
<tr>
|
16
|
+
<td>Получатель</td>
|
17
|
+
<td><input id="receiver" type="email" name="receiver" placeholder="E-mail получателя"></td>
|
18
|
+
</tr>
|
19
|
+
|
20
|
+
<tr>
|
21
|
+
<td>Тема</td>
|
22
|
+
<td><input id="subject" type="text" name="subject" placeholder="Тема сообщения"></td>
|
23
|
+
</tr>
|
24
|
+
|
25
|
+
<tr>
|
26
|
+
<td>Сообщение</td>
|
27
|
+
<td><input id="message" type="text" name="message" placeholder="Ваше сообщение"></td>
|
28
|
+
</tr>
|
29
|
+
</table>
|
30
|
+
<button type="submit">Отправить</button>
|
31
|
+
</form>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
</body>
|
35
|
+
</html>
|
package/05_02.js
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
const http = require('http');
|
2
|
+
const url = require('url');
|
3
|
+
const fs = require('fs');
|
4
|
+
const { parse } = require('querystring');
|
5
|
+
const nodemailer = require('nodemailer');
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
http.createServer((request, response) => {
|
10
|
+
response.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
11
|
+
|
12
|
+
if (url.parse(request.url).pathname === '/' && request.method === 'GET')
|
13
|
+
{
|
14
|
+
response.end(fs.readFileSync('./05_02.html'));
|
15
|
+
}
|
16
|
+
else if (url.parse(request.url).pathname === '/' && request.method === 'POST')
|
17
|
+
{
|
18
|
+
let body = '';
|
19
|
+
request.on('data', chunk => { body += chunk.toString(); });
|
20
|
+
|
21
|
+
request.on('end', () => {
|
22
|
+
let parm = parse(body);
|
23
|
+
const transporter = nodemailer.createTransport({
|
24
|
+
host: 'smtp.gmail.com',
|
25
|
+
port: 465,
|
26
|
+
secure: false,
|
27
|
+
service: 'Gmail',
|
28
|
+
auth: {
|
29
|
+
user: parm.sender,
|
30
|
+
pass: parm.password
|
31
|
+
}
|
32
|
+
});
|
33
|
+
|
34
|
+
const mailOptions = {
|
35
|
+
from: parm.sender,
|
36
|
+
to: parm.receiver,
|
37
|
+
subject: parm.subject,
|
38
|
+
text: parm.message
|
39
|
+
}
|
40
|
+
|
41
|
+
transporter.sendMail(mailOptions, (err, info) => {
|
42
|
+
err ? console.log(err) : console.log('Sent: ' + info.response);
|
43
|
+
})
|
44
|
+
|
45
|
+
response.end(`<h2>Отправитель: ${parm.sender}</br>Получатель: ${parm.receiver}
|
46
|
+
</br>Тема: ${parm.subject}</br>Сообщение: ${parm.message}</h2>`);
|
47
|
+
})
|
48
|
+
}
|
49
|
+
|
50
|
+
else
|
51
|
+
response.end('<html><body><h1>Error! Visit localhost:5000/</h1></body></html>');
|
52
|
+
}).listen(5000, () => console.log('Server running on http://localhost:5000/\n'));
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
package/05_03.js
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
const http = require('http');
|
2
|
+
const send = require('./m06_ZKM.js');
|
3
|
+
|
4
|
+
http.createServer((request, response) => {
|
5
|
+
response.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
6
|
+
send('Hello World!');
|
7
|
+
response.end('<h2>Message sucessfully sent.</h2>');
|
8
|
+
}).listen(5000, () => console.log('Server running on http://localhost:5000/\n'));
|
package/05_04.js
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
const send = require("C:\\Users\\kseni\\AppData\\Roaming\\npm\\node_modules\\qwerty5");
|
3
|
+
const http = require('http');
|
4
|
+
|
5
|
+
http.createServer((req, res) => {
|
6
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
7
|
+
send('Hello world! Global module');
|
8
|
+
res.end('<h2>Message sucessfully sent.</h2>');
|
9
|
+
}).listen(5000, () => console.log('Server running on http://localhost:5000/\n'));
|
package/m06_ZKM.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
const nodemailer = require('nodemailer');
|
2
|
+
|
3
|
+
const sender = 'kseniazhuk84@gmail.com';
|
4
|
+
const receiver = 'kseniazhuk84@gmail.com';
|
5
|
+
const password = 'kuth gqqh bmog pdkp';
|
6
|
+
|
7
|
+
|
8
|
+
const transporter = nodemailer.createTransport({
|
9
|
+
host: 'smtp.gmail.com',
|
10
|
+
port: 465,
|
11
|
+
secure: false,
|
12
|
+
service: 'Gmail',
|
13
|
+
auth: {
|
14
|
+
user: sender,
|
15
|
+
pass: password
|
16
|
+
}
|
17
|
+
});
|
18
|
+
|
19
|
+
|
20
|
+
send = (message) =>
|
21
|
+
{
|
22
|
+
const mailOptions = {
|
23
|
+
from: sender,
|
24
|
+
to: receiver,
|
25
|
+
subject: 'Module m06_ZKM',
|
26
|
+
text: message
|
27
|
+
}
|
28
|
+
|
29
|
+
transporter.sendMail(mailOptions, (err, info) => {
|
30
|
+
err ? console.log(err) : console.log('Sent: ' + info.response);
|
31
|
+
})
|
32
|
+
}
|
33
|
+
|
34
|
+
module.exports = send;
|
package/package.json
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"name": "zkmlab05",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "m06_ZKM.js",
|
6
|
+
"dependencies": {
|
7
|
+
"httpntlm": "^1.6.1",
|
8
|
+
"httpreq": "^1.1.1",
|
9
|
+
"nodemailer": "^6.9.7",
|
10
|
+
"nodemailer-fetch": "^1.6.0",
|
11
|
+
"nodemailer-shared": "^1.1.0",
|
12
|
+
"nodemailer-smtp-transport": "^2.7.4",
|
13
|
+
"nodemailer-wellknown": "^0.1.10",
|
14
|
+
"qwerty5": "^1.0.0",
|
15
|
+
"smtp-connection": "^2.12.0",
|
16
|
+
"underscore": "^1.7.0"
|
17
|
+
},
|
18
|
+
"devDependencies": {},
|
19
|
+
"scripts": {
|
20
|
+
"test": "test"
|
21
|
+
},
|
22
|
+
"repository": {
|
23
|
+
"type": "git",
|
24
|
+
"url": "git"
|
25
|
+
},
|
26
|
+
"author": "Zhuk Ksenia",
|
27
|
+
"license": "ISC"
|
28
|
+
}
|