savlab05 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of savlab05 might be problematic. Click here for more details.

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_SAV.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\\zerraeh\\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_SAV.js ADDED
@@ -0,0 +1,34 @@
1
+ const nodemailer = require('nodemailer');
2
+
3
+ const sender = 'totsamiysano@gmail.com';
4
+ const receiver = 'totsamiysano@gmail.com';
5
+ const password = 'gxgm ypht xdgv nvga';
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_SAV',
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,20 @@
1
+ {
2
+ "dependencies": {
3
+ "nodemailer": "^6.9.7",
4
+ "nodemailer-smtp-transport": "^2.7.4"
5
+ },
6
+ "name": "savlab05",
7
+ "version": "1.0.0",
8
+ "description": "lab5",
9
+ "main": "m06_SAV.js",
10
+ "scripts": {
11
+ "test": "test"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git"
16
+ },
17
+ "author": "S",
18
+ "license": "ISC",
19
+ "devDependencies": {}
20
+ }