m06-03raa11 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.
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptLibraryMappings">
4
+ <includedPredefinedLibrary name="Node.js Core" />
5
+ </component>
6
+ </project>
package/.idea/lab5.iml ADDED
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/lab5.iml" filepath="$PROJECT_DIR$/.idea/lab5.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/06-02.html ADDED
@@ -0,0 +1,76 @@
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="password" type="password" name="password" placeholder="Ваш пароль"></td>
53
+ </tr>
54
+
55
+ <tr>
56
+ <td>Получатель</td>
57
+ <td><input id="receiver" type="email" name="receiver" placeholder="E-mail получателя"></td>
58
+ </tr>
59
+
60
+ <tr>
61
+ <td>Тема</td>
62
+ <td><input id="subject" type="text" name="subject" placeholder="Тема сообщения"></td>
63
+ </tr>
64
+
65
+ <tr>
66
+ <td>Сообщение</td>
67
+ <td><input id="message" type="text" name="message" placeholder="Ваше сообщение"></td>
68
+ </tr>
69
+ </table>
70
+
71
+ <button type="submit">Отправить</button>
72
+ </form>
73
+ </div>
74
+
75
+ </body>
76
+ </html>
package/06-02.js ADDED
@@ -0,0 +1,57 @@
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('./06-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
+ console.log(`${parm.sender},${parm.password}`);
24
+ const transporter = nodemailer.createTransport({
25
+ //y9GUhRzuqtiXwXwvGhih
26
+ host: 'smtp.mail.ru',
27
+ port: 465,
28
+ secure: false,
29
+ service: 'mail.ru',
30
+ auth: {
31
+ user: parm.sender,
32
+ pass: parm.password
33
+ },
34
+ });
35
+
36
+ const mailOptions = {
37
+ from: parm.sender,
38
+ to: parm.receiver,
39
+ subject: parm.subject,
40
+ text: parm.message
41
+ }
42
+
43
+ transporter.sendMail(mailOptions, (err, info) => {
44
+ err ? console.log(err) : console.log('Sent: ' + info.response);
45
+ })
46
+
47
+ response.end(`<h2>Отправитель: ${parm.sender}</br>Получатель: ${parm.receiver}
48
+ </br>Тема: ${parm.subject}</br>Сообщение: ${parm.message}</h2>`);
49
+ })
50
+ }
51
+
52
+ else
53
+ response.end('<html><body><h1>Error! Visit localhost:5000/</h1></body></html>');
54
+ }).listen(5000, () => console.log('Server running at localhost:5000/\n'));
55
+
56
+
57
+
package/06-03.js ADDED
@@ -0,0 +1,8 @@
1
+ const http = require('http');
2
+ const send = require('./m06-03RAA.js');
3
+
4
+ http.createServer((request, response) => {
5
+ response.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
6
+ send("mrfiref@mail.ru","y9GUhRzuqtiXwXwvGhih",'я просто хочу жить)');
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 http = require('http');
2
+ const send = require('m06-03raa');
3
+
4
+ http.createServer((request, response) => {
5
+ response.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
6
+ send("mrfiref@mail.ru","y9GUhRzuqtiXwXwvGhih",'я просто хочу жить)');
7
+ response.end('<h2>Message sucessfully sent.</h2>');
8
+ }).listen(5000, () => console.log('Server running at localhost:5000/\n'));
package/m06-03RAA.js ADDED
@@ -0,0 +1,30 @@
1
+ const nodemailer = require('nodemailer');
2
+ const receiver = "rubasheka@gmail.com";
3
+
4
+ send = (mailAddr,mailPass,message) =>
5
+ {
6
+ console.log("зашли");
7
+ const transporter = nodemailer.createTransport({
8
+ host: 'smtp.mail.ru',
9
+ port: 465,
10
+ secure: false,
11
+ service: 'mail.ru',
12
+ auth: {
13
+ user: mailAddr,
14
+ pass: mailPass
15
+ }
16
+ });
17
+
18
+ const mailOptions = {
19
+ from: mailAddr,
20
+ to: receiver,
21
+ subject: 'Module m06-03RAA',
22
+ text: message
23
+ };
24
+
25
+ transporter.sendMail(mailOptions, (err, info) => {
26
+ err ? console.log(err) : console.log('Sent: ' + info.response);
27
+ });
28
+ }
29
+
30
+ module.exports = send;
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "m06-03raa11",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "m06-03RAA.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "nodemailer": "^6.9.6"
13
+ }
14
+ }