m0603rsd 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 m0603rsd might be problematic. Click here for more details.

package/06-02.js ADDED
@@ -0,0 +1,55 @@
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
+ const password = require('D:/unik/pskp/pswrd');
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('./index.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
+
24
+ const transporter = nodemailer.createTransport({
25
+ host: 'smtp.gmail.com',
26
+ port: 465,
27
+ secure: false,
28
+ service: 'Gmail',
29
+ auth: {
30
+ user: parm.sender,
31
+ pass: password
32
+ }
33
+ });
34
+
35
+ const mailOptions = {
36
+ from: parm.sender,
37
+ to: parm.receiver,
38
+ subject: parm.subject,
39
+ text: parm.message
40
+ }
41
+
42
+ transporter.sendMail(mailOptions, (err, info) => {
43
+ err ? console.log(err) : console.log('Sent: ' + info.response);
44
+ })
45
+
46
+ response.end(`<h2>Отправитель: ${parm.sender}</br>Получатель: ${parm.receiver}
47
+ </br>Тема: ${parm.subject}</br>Сообщение: ${parm.message}</h2>`);
48
+ })
49
+ }
50
+
51
+ else
52
+ response.end('<html><body><h1>Error! Visit localhost:5000/</h1></body></html>');
53
+ }).listen(5000, () => console.log('Server running at localhost:5000/\n'));
54
+
55
+
package/06-03.js ADDED
@@ -0,0 +1,8 @@
1
+ const http = require('http');
2
+ const send = require('./m0603.js');
3
+
4
+ http.createServer((request, response) => {
5
+ response.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
6
+ send('Смелов В. В.');
7
+ response.end('<h2>Message sucessfully sent.</h2>');
8
+ }).listen(5000, () => console.log('Server running at localhost:5000/\n'));
package/06-04.js ADDED
@@ -0,0 +1,8 @@
1
+ const send = require('');
2
+ const http = require('http');
3
+
4
+ http.createServer((req, res) => {
5
+ res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
6
+ send('npm module test');
7
+ res.end('<h2>Message sucessfully sent.</h2>');
8
+ }).listen(5000, () => console.log('Server running at localhost:5000/\n'));
package/index.html ADDED
@@ -0,0 +1,71 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <style type="text/css">
7
+ * {
8
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
9
+ font-size: 18px;
10
+ }
11
+
12
+ input {
13
+ height: 32px;
14
+ width: 250px;
15
+ border: 1px solid #dbdbdb;
16
+ border-radius: 4px;
17
+ padding: 5px;
18
+ }
19
+
20
+ button {
21
+ height: 2em;
22
+ font-size: 1rem;
23
+ background-color: rgb(248, 248, 248);
24
+ color: #2f2f2f;
25
+ border: 1px solid #c4c4c4;
26
+ border-radius: 4px;
27
+ margin: 10px 10px;
28
+ cursor: pointer;
29
+ }
30
+
31
+ td {
32
+ padding: 12px 10px;
33
+ }
34
+
35
+ </style>
36
+
37
+ </head>
38
+
39
+
40
+
41
+ <body>
42
+ <div id="container">
43
+ <form action="http://localhost:5000/" method="POST">
44
+ <table id="container_table">
45
+ <tr>
46
+ <td>Отправитель</td>
47
+ <td><input id="sender" type="email" name="sender" placeholder="Ваш e-mail"></td>
48
+ </tr>
49
+
50
+ <tr>
51
+ <td>Получатель</td>
52
+ <td><input id="receiver" type="email" name="receiver" placeholder="E-mail получателя"></td>
53
+ </tr>
54
+
55
+ <tr>
56
+ <td>Тема</td>
57
+ <td><input id="subject" type="text" name="subject" placeholder="Тема сообщения"></td>
58
+ </tr>
59
+
60
+ <tr>
61
+ <td>Сообщение</td>
62
+ <td><input id="message" type="text" name="message" placeholder="Ваше сообщение"></td>
63
+ </tr>
64
+ </table>
65
+
66
+ <button type="submit">Отправить</button>
67
+ </form>
68
+ </div>
69
+
70
+ </body>
71
+ </html>
package/m0603.js ADDED
@@ -0,0 +1,37 @@
1
+ const nodemailer = require('nodemailer');
2
+
3
+
4
+
5
+ const sender = 'belstustudent@gmail.com';
6
+ const receiver = 'belstustudent@gmail.com';
7
+ const password = require('D:/unik/pskp/pswrd');
8
+
9
+
10
+ const transporter = nodemailer.createTransport({
11
+ host: 'smtp.gmail.com',
12
+ port: 465,
13
+ secure: false,
14
+ service: 'Gmail',
15
+ auth: {
16
+ user: sender,
17
+ pass: password
18
+ }
19
+ });
20
+
21
+
22
+ send = (message) =>
23
+ {
24
+
25
+ const mailOptions = {
26
+ from: sender,
27
+ to: receiver,
28
+ subject: 'Module m0306',
29
+ text: message
30
+ }
31
+
32
+ transporter.sendMail(mailOptions, (err, info) => {
33
+ err ? console.log(err) : console.log('Sent: ' + info.response);
34
+ })
35
+ }
36
+
37
+ module.exports = send;
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "dependencies": {
3
+ "nodemailer": "^6.8.0",
4
+ "sendmail": "^1.6.1"
5
+ },
6
+ "name": "m0603rsd",
7
+ "version": "1.0.0",
8
+ "main": "06-02.js",
9
+ "devDependencies": {},
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "author": "",
14
+ "license": "ISC",
15
+ "description": ""
16
+ }