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

@@ -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/lw5.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$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
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/lw5.iml" filepath="$PROJECT_DIR$/.idea/lw5.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+ </component>
6
+ </project>
package/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 };
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "m0603_adamovich",
3
+ "version": "1.0.0",
4
+ "description": "m0603 package for sending message through nodemailer",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "kapold",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "express": "^4.18.2",
14
+ "nodemailer": "^6.9.1"
15
+ },
16
+ "devDependencies": {}
17
+ }
package/task1.js ADDED
@@ -0,0 +1,3 @@
1
+ // 1. npm view nodemailer
2
+ // 2. npm install nodemailer
3
+ // 3. npm ls nodemailer
package/task2.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><br>
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/task2.js ADDED
@@ -0,0 +1,43 @@
1
+ const express = require('express');
2
+ const nodemailer = require('nodemailer');
3
+
4
+
5
+ const app = express();
6
+ app.use(express.urlencoded({ extended: true }));
7
+ app.use(express.static('public'));
8
+
9
+ app.get('/', (req, res) => {
10
+ res.sendFile(__dirname + '/task2.html');
11
+ });
12
+
13
+ app.post('/send', (req, res) => {
14
+ const transporter = nodemailer.createTransport({
15
+ host: "smtp.mail.ru",
16
+ port: 465,
17
+ secure: true,
18
+ auth: {
19
+ user: 'antonadamovich@mail.ru',
20
+ // пароль нужно генерить в почте отдельно для сторонних приложений
21
+ pass: 'HnCHsiL9Lj83h94iXhAi'
22
+ }
23
+ });
24
+
25
+ const mailOptions = {
26
+ from: req.body.from,
27
+ to: req.body.to,
28
+ subject: req.body.subject,
29
+ html: req.body.message
30
+ };
31
+
32
+ transporter.sendMail(mailOptions, (error, info) => {
33
+ if (error) {
34
+ console.log(error);
35
+ res.send('Error: Something went wrong.');
36
+ } else {
37
+ console.log('Email sent: ' + info.response);
38
+ res.send('Email sent successfully!');
39
+ }
40
+ });
41
+ }).listen(3000, () => {
42
+ console.log('Server started on port http://localhost:3000');
43
+ });
package/task3.js ADDED
@@ -0,0 +1,7 @@
1
+ const m0603 = require('./m0603');
2
+
3
+ const fromEmail = 'antonadamovich@mail.ru';
4
+ const toEmail = 'antonadamovichmaksimovich@gmail.com';
5
+ const password = 'HnCHsiL9Lj83h94iXhAi';
6
+
7
+ m0603.send(fromEmail, password, toEmail, 'Hello from m0603 module!');
package/task4.js ADDED
File without changes