zhuha 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 zhuha might be problematic. Click here for more details.
- package/06-02.html +81 -0
- package/06-02.js +72 -0
- package/06-03.js +7 -0
- package/06-04.js +7 -0
- package/AnswersLW5.pdf +0 -0
- package/m0603/m0603.js +30 -0
- package/m0603/node_modules/.package-lock.json +16 -0
- package/m0603/node_modules/nodemailer/.gitattributes +6 -0
- package/m0603/node_modules/nodemailer/.prettierrc.js +8 -0
- package/m0603/node_modules/nodemailer/CHANGELOG.md +725 -0
- package/m0603/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
- package/m0603/node_modules/nodemailer/CONTRIBUTING.md +67 -0
- package/m0603/node_modules/nodemailer/LICENSE +16 -0
- package/m0603/node_modules/nodemailer/README.md +97 -0
- package/m0603/node_modules/nodemailer/SECURITY.txt +22 -0
- package/m0603/node_modules/nodemailer/lib/addressparser/index.js +313 -0
- package/m0603/node_modules/nodemailer/lib/base64/index.js +142 -0
- package/m0603/node_modules/nodemailer/lib/dkim/index.js +251 -0
- package/m0603/node_modules/nodemailer/lib/dkim/message-parser.js +155 -0
- package/m0603/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
- package/m0603/node_modules/nodemailer/lib/dkim/sign.js +117 -0
- package/m0603/node_modules/nodemailer/lib/fetch/cookies.js +281 -0
- package/m0603/node_modules/nodemailer/lib/fetch/index.js +274 -0
- package/m0603/node_modules/nodemailer/lib/json-transport/index.js +82 -0
- package/m0603/node_modules/nodemailer/lib/mail-composer/index.js +558 -0
- package/m0603/node_modules/nodemailer/lib/mailer/index.js +427 -0
- package/m0603/node_modules/nodemailer/lib/mailer/mail-message.js +315 -0
- package/m0603/node_modules/nodemailer/lib/mime-funcs/index.js +625 -0
- package/m0603/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2102 -0
- package/m0603/node_modules/nodemailer/lib/mime-node/index.js +1290 -0
- package/m0603/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
- package/m0603/node_modules/nodemailer/lib/mime-node/le-unix.js +43 -0
- package/m0603/node_modules/nodemailer/lib/mime-node/le-windows.js +52 -0
- package/m0603/node_modules/nodemailer/lib/nodemailer.js +143 -0
- package/m0603/node_modules/nodemailer/lib/qp/index.js +219 -0
- package/m0603/node_modules/nodemailer/lib/sendmail-transport/index.js +210 -0
- package/m0603/node_modules/nodemailer/lib/ses-transport/index.js +349 -0
- package/m0603/node_modules/nodemailer/lib/shared/index.js +638 -0
- package/m0603/node_modules/nodemailer/lib/smtp-connection/data-stream.js +108 -0
- package/m0603/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +143 -0
- package/m0603/node_modules/nodemailer/lib/smtp-connection/index.js +1796 -0
- package/m0603/node_modules/nodemailer/lib/smtp-pool/index.js +648 -0
- package/m0603/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +253 -0
- package/m0603/node_modules/nodemailer/lib/smtp-transport/index.js +416 -0
- package/m0603/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
- package/m0603/node_modules/nodemailer/lib/well-known/index.js +47 -0
- package/m0603/node_modules/nodemailer/lib/well-known/services.json +286 -0
- package/m0603/node_modules/nodemailer/lib/xoauth2/index.js +376 -0
- package/m0603/node_modules/nodemailer/package.json +46 -0
- package/m0603/node_modules/nodemailer/postinstall.js +101 -0
- package/m0603/package-lock.json +31 -0
- package/m0603/package.json +15 -0
- package/package.json +16 -0
package/06-02.html
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Send Email</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
font-family: Arial, sans-serif;
|
8
|
+
font-size: 16px;
|
9
|
+
}
|
10
|
+
|
11
|
+
.container {
|
12
|
+
max-width: 600px;
|
13
|
+
margin: 0 auto;
|
14
|
+
text-align: center;
|
15
|
+
}
|
16
|
+
|
17
|
+
h1 {
|
18
|
+
color: #333;
|
19
|
+
font-size: 28px;
|
20
|
+
}
|
21
|
+
|
22
|
+
form {
|
23
|
+
display: flex;
|
24
|
+
flex-direction: column;
|
25
|
+
}
|
26
|
+
|
27
|
+
label {
|
28
|
+
display: inline-block;
|
29
|
+
width: 100px;
|
30
|
+
text-align: left;
|
31
|
+
}
|
32
|
+
|
33
|
+
input[type="email"], input[type="text"], textarea {
|
34
|
+
width: 100%;
|
35
|
+
padding: 10px;
|
36
|
+
border: 1px solid #ccc;
|
37
|
+
border-radius: 5px;
|
38
|
+
box-sizing: border-box;
|
39
|
+
}
|
40
|
+
|
41
|
+
textarea {
|
42
|
+
height: 100px;
|
43
|
+
}
|
44
|
+
|
45
|
+
button[type="submit"] {
|
46
|
+
background-color: #4CAF50;
|
47
|
+
color: white;
|
48
|
+
padding: 12px 20px;
|
49
|
+
border: none;
|
50
|
+
border-radius: 4px;
|
51
|
+
cursor: pointer;
|
52
|
+
font-size: 16px;
|
53
|
+
}
|
54
|
+
|
55
|
+
button[type="submit"]:hover {
|
56
|
+
background-color: #45a049;
|
57
|
+
}
|
58
|
+
</style>
|
59
|
+
</head>
|
60
|
+
<body>
|
61
|
+
<div class="container">
|
62
|
+
<h1>Send Email</h1>
|
63
|
+
<form method="post" action="/send">
|
64
|
+
|
65
|
+
<label for="from">From:</label>
|
66
|
+
<input type="email" id="from" name="from" required><br><br>
|
67
|
+
|
68
|
+
<label for="to">To:</label>
|
69
|
+
<input type="email" id="to" name="to" required><br><br>
|
70
|
+
|
71
|
+
<label for="subject">Subject:</label>
|
72
|
+
<input type="text" id="subject" name="subject" required><br><br>
|
73
|
+
|
74
|
+
<label for="message">Message:</label>
|
75
|
+
<textarea id="message" name="message" rows="10" cols="30" required></textarea><br><br>
|
76
|
+
|
77
|
+
<button type="submit">Send</button>
|
78
|
+
</div>
|
79
|
+
</form>
|
80
|
+
</body>
|
81
|
+
</html>
|
package/06-02.js
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
const http = require("http");
|
2
|
+
const url = require("url");
|
3
|
+
const nodemailer = require("nodemailer");
|
4
|
+
const fs = require("fs");
|
5
|
+
const path = require("path");
|
6
|
+
|
7
|
+
const server = http.createServer((req, res) => {
|
8
|
+
const pathName = url.parse(req.url, true).pathname;
|
9
|
+
|
10
|
+
if (pathName === "/") {
|
11
|
+
const filePath = path.join(__dirname, "06-02.html");
|
12
|
+
fs.readFile(filePath, (err, data) => {
|
13
|
+
if (err) {
|
14
|
+
res.writeHead(404, { "Content-Type": "text/html" });
|
15
|
+
res.write("<h1>404 Not Found</h1>");
|
16
|
+
res.end();
|
17
|
+
} else {
|
18
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
19
|
+
res.write(data);
|
20
|
+
res.end();
|
21
|
+
}
|
22
|
+
});
|
23
|
+
} else if (pathName === "/send" && req.method === "POST") {
|
24
|
+
let body = "";
|
25
|
+
|
26
|
+
req.on("data", (chunk) => {
|
27
|
+
body += chunk.toString();
|
28
|
+
});
|
29
|
+
|
30
|
+
req.on("end", () => {
|
31
|
+
const transporter = nodemailer.createTransport({
|
32
|
+
host: "smtp.mail.ru",
|
33
|
+
port: 465,
|
34
|
+
secure: true,
|
35
|
+
auth: {
|
36
|
+
user: 'vlad-ju@mail.ru',
|
37
|
+
pass: '4UHWqhy0Hf1yuwWvkniP'
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
const parsedBody = new URLSearchParams(body);
|
42
|
+
const mailOptions = {
|
43
|
+
from: parsedBody.get("from"),
|
44
|
+
to: parsedBody.get("to"),
|
45
|
+
subject: parsedBody.get("subject"),
|
46
|
+
html: parsedBody.get("message"),
|
47
|
+
};
|
48
|
+
|
49
|
+
transporter.sendMail(mailOptions, (error, info) => {
|
50
|
+
if (error) {
|
51
|
+
console.log(error);
|
52
|
+
res.writeHead(500, { "Content-Type": "text/html" });
|
53
|
+
res.write("<h1>Error: Something went wrong.</h1>");
|
54
|
+
res.end();
|
55
|
+
} else {
|
56
|
+
console.log("Email sent: " + info.response);
|
57
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
58
|
+
res.write("<h1>Email sent successfully!</h1>");
|
59
|
+
res.end();
|
60
|
+
}
|
61
|
+
});
|
62
|
+
});
|
63
|
+
} else {
|
64
|
+
res.writeHead(404, { "Content-Type": "text/html" });
|
65
|
+
res.write("<h1>404 Not Found</h1>");
|
66
|
+
res.end();
|
67
|
+
}
|
68
|
+
});
|
69
|
+
|
70
|
+
server.listen(3000, () => {
|
71
|
+
console.log("Server started on port http://localhost:3000");
|
72
|
+
});
|
package/06-03.js
ADDED
package/06-04.js
ADDED
package/AnswersLW5.pdf
ADDED
Binary file
|
package/m0603/m0603.js
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
const nodemailer = require('nodemailer');
|
2
|
+
|
3
|
+
function send(from, password, to, message) {
|
4
|
+
let transporter = nodemailer.createTransport({
|
5
|
+
host: "smtp.mail.ru",
|
6
|
+
port: 465,
|
7
|
+
secure: true,
|
8
|
+
auth: {
|
9
|
+
user: from,
|
10
|
+
pass: password
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
let mailOptions = {
|
15
|
+
from: from,
|
16
|
+
to: to,
|
17
|
+
subject: 'Message from m0603 module',
|
18
|
+
text: message
|
19
|
+
};
|
20
|
+
|
21
|
+
transporter.sendMail(mailOptions, (error, info) => {
|
22
|
+
if (error) {
|
23
|
+
console.log(error);
|
24
|
+
} else {
|
25
|
+
console.log('Message sent: %s', info.messageId);
|
26
|
+
}
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports = { send };
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"name": "m0603-001",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"lockfileVersion": 2,
|
5
|
+
"requires": true,
|
6
|
+
"packages": {
|
7
|
+
"node_modules/nodemailer": {
|
8
|
+
"version": "6.9.1",
|
9
|
+
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.1.tgz",
|
10
|
+
"integrity": "sha512-qHw7dOiU5UKNnQpXktdgQ1d3OFgRAekuvbJLcdG5dnEo/GtcTHRYM7+UfJARdOFU9WUQO8OiIamgWPmiSFHYAA==",
|
11
|
+
"engines": {
|
12
|
+
"node": ">=6.0.0"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|