pvg_m05 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 pvg_m05 might be problematic. Click here for more details.
- package/06-02.html +49 -0
- package/06-02.js +53 -0
- package/06-03.js +13 -0
- package/06-04.js +13 -0
- package/m0603.js +31 -0
- package/m06_PVG.js +29 -0
- package/package.json +17 -0
    
        package/06-02.html
    ADDED
    
    | @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            <!DOCTYPE html>
         | 
| 2 | 
            +
            <html lang="en">
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            <head>
         | 
| 5 | 
            +
                <meta charset="UTF-8" />
         | 
| 6 | 
            +
                <style type="text/css">
         | 
| 7 | 
            +
                    * {
         | 
| 8 | 
            +
                        color: black;
         | 
| 9 | 
            +
                        text-align: center;
         | 
| 10 | 
            +
                        font-size: 14pt;
         | 
| 11 | 
            +
                        margin-top: 5px;
         | 
| 12 | 
            +
                    }
         | 
| 13 | 
            +
                    
         | 
| 14 | 
            +
                    button {
         | 
| 15 | 
            +
                        background-color: lavender;
         | 
| 16 | 
            +
                        padding: 8px 15px;
         | 
| 17 | 
            +
                        font-size: 14pt;
         | 
| 18 | 
            +
                        border-radius: 5px;
         | 
| 19 | 
            +
                    }
         | 
| 20 | 
            +
                </style>
         | 
| 21 | 
            +
            </head>
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            <body>
         | 
| 24 | 
            +
                <div>
         | 
| 25 | 
            +
                    <div>
         | 
| 26 | 
            +
                        <form action="http://localhost:5000/" method="POST">
         | 
| 27 | 
            +
                            <div>
         | 
| 28 | 
            +
                                <label>Sender:</label>
         | 
| 29 | 
            +
                                <input type="email" name="sender" required style="margin-right: -18px" /><br />
         | 
| 30 | 
            +
                            </div>
         | 
| 31 | 
            +
                            <div>
         | 
| 32 | 
            +
                                <label>Password:</label>
         | 
| 33 | 
            +
                                <input type="password" name="password" required /><br />
         | 
| 34 | 
            +
                            </div>
         | 
| 35 | 
            +
                            <div>
         | 
| 36 | 
            +
                                <label>Receiver:</label>
         | 
| 37 | 
            +
                                <input type="email" name="receiver" required style="margin-right: -5px" /><br />
         | 
| 38 | 
            +
                            </div>
         | 
| 39 | 
            +
                            <div>
         | 
| 40 | 
            +
                                <label>Message:</label>
         | 
| 41 | 
            +
                                <input type="text" name="message" required style="margin-right: -5px" /><br />
         | 
| 42 | 
            +
                            </div>
         | 
| 43 | 
            +
                            <button type="submit" style="margin-right: -85px">Send</button>
         | 
| 44 | 
            +
                        </form>
         | 
| 45 | 
            +
                    </div>
         | 
| 46 | 
            +
                </div>
         | 
| 47 | 
            +
            </body>
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            </html>
         | 
    
        package/06-02.js
    ADDED
    
    | @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            const http = require("http");
         | 
| 2 | 
            +
            const url = require("url");
         | 
| 3 | 
            +
            const fs = require("fs");
         | 
| 4 | 
            +
            const nodemailer = require("nodemailer");
         | 
| 5 | 
            +
            const {parse} =require('querystring');
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            const server = http.createServer().listen(5000);
         | 
| 8 | 
            +
            console.log("http://localhost:5000/");
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            server.on("request", (req, res) => {
         | 
| 11 | 
            +
                const path = url.parse(req.url).pathname;
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                if (path === "/" && req.method === "GET") {
         | 
| 14 | 
            +
                    fs.readFile("06-02.html", (err, data) => {
         | 
| 15 | 
            +
                        if (err) {
         | 
| 16 | 
            +
                            console.error(err);
         | 
| 17 | 
            +
                            return;
         | 
| 18 | 
            +
                        }
         | 
| 19 | 
            +
                        res.writeHead(200, { "Content-Type": "text/html" });
         | 
| 20 | 
            +
                        res.end(data);
         | 
| 21 | 
            +
                    });
         | 
| 22 | 
            +
                } else if (path === "/" && req.method === "POST") {
         | 
| 23 | 
            +
                    let body = "";
         | 
| 24 | 
            +
                    req.on("data", (chunk) => {
         | 
| 25 | 
            +
                        body += chunk.toString();
         | 
| 26 | 
            +
                    });
         | 
| 27 | 
            +
                    
         | 
| 28 | 
            +
                    req.on("end", () => {
         | 
| 29 | 
            +
                        let params = parse(body);
         | 
| 30 | 
            +
                        const transporter = nodemailer.createTransport({
         | 
| 31 | 
            +
                            service: 'Gmail',
         | 
| 32 | 
            +
                            auth: {
         | 
| 33 | 
            +
                                user: params.sender,
         | 
| 34 | 
            +
                                pass: params.password,
         | 
| 35 | 
            +
                            },
         | 
| 36 | 
            +
                        });
         | 
| 37 | 
            +
                        
         | 
| 38 | 
            +
                        const options = {
         | 
| 39 | 
            +
                            from: params.sender,
         | 
| 40 | 
            +
                            to: params.receiver,
         | 
| 41 | 
            +
                            subject: "Lab №5 task-2",
         | 
| 42 | 
            +
                            text: params.message,
         | 
| 43 | 
            +
                        };
         | 
| 44 | 
            +
                        
         | 
| 45 | 
            +
                        transporter.sendMail(options, (err, info) => {
         | 
| 46 | 
            +
                            err ? console.log(err):console.log('Email sent')
         | 
| 47 | 
            +
                        })
         | 
| 48 | 
            +
                        
         | 
| 49 | 
            +
                        res.writeHead(200, { "Content-Type": "text/html" });
         | 
| 50 | 
            +
                        res.end(`<h1>${params.message}</h1>`);
         | 
| 51 | 
            +
                    })
         | 
| 52 | 
            +
                }
         | 
| 53 | 
            +
            });
         | 
    
        package/06-03.js
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            const { send } = require('./m0603.js');
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            let mailAddr = "mama2003271@gmail.com";
         | 
| 4 | 
            +
            let mailPass = "soek zxgk nraf rqmk";
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            send(mailAddr, mailPass, "Привет")
         | 
| 7 | 
            +
                .then(info => {
         | 
| 8 | 
            +
                    console.log("Почтовое сообщение успешно отправлено!");
         | 
| 9 | 
            +
                    console.log("Дополнительная информация о сообщении:", info);
         | 
| 10 | 
            +
                })
         | 
| 11 | 
            +
                .catch(error => {
         | 
| 12 | 
            +
                    console.log("Ошибка при отправке почтового сообщения:", error);
         | 
| 13 | 
            +
                });
         | 
    
        package/06-04.js
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            const m06 = require('pvg_m05');
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            let mailAddr = "mama2003271@gmail.com";
         | 
| 4 | 
            +
            let mailPass = "soek zxgk nraf rqmk";
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            m06.send(mailAddr, mailPass, "Hello from application 06-04!")
         | 
| 7 | 
            +
               .then(info => {
         | 
| 8 | 
            +
                   console.log("Email sent successfully!");
         | 
| 9 | 
            +
                   console.log("Additional information:", info);
         | 
| 10 | 
            +
               })
         | 
| 11 | 
            +
               .catch(error => {
         | 
| 12 | 
            +
                   console.log("Error sending email:", error);
         | 
| 13 | 
            +
               });
         | 
    
        package/m0603.js
    ADDED
    
    | @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            const nodemailer = require("nodemailer");
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            const send = (mailAddr, mailPass, message) => {
         | 
| 4 | 
            +
                const options = {
         | 
| 5 | 
            +
                    from: mailAddr,
         | 
| 6 | 
            +
                    to: mailAddr,
         | 
| 7 | 
            +
                    subject: "Lab05 task #3",
         | 
| 8 | 
            +
                    text: message,
         | 
| 9 | 
            +
                };
         | 
| 10 | 
            +
                const transporter = nodemailer.createTransport({
         | 
| 11 | 
            +
                    host: 'smtp.gmail.com',
         | 
| 12 | 
            +
                    port: 465,
         | 
| 13 | 
            +
                    secure: true,
         | 
| 14 | 
            +
                    auth: {
         | 
| 15 | 
            +
                        user: mailAddr,
         | 
| 16 | 
            +
                        pass: mailPass,
         | 
| 17 | 
            +
                    },
         | 
| 18 | 
            +
                });
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                return new Promise((resolve, reject) => {
         | 
| 21 | 
            +
                    transporter.sendMail(options, (err, info) => {
         | 
| 22 | 
            +
                        if (err) {
         | 
| 23 | 
            +
                            reject(err);
         | 
| 24 | 
            +
                        } else {
         | 
| 25 | 
            +
                            resolve(info);
         | 
| 26 | 
            +
                        }
         | 
| 27 | 
            +
                    });
         | 
| 28 | 
            +
                });
         | 
| 29 | 
            +
            }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            exports.send = send;
         | 
    
        package/m06_PVG.js
    ADDED
    
    | @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            const send = (mailAddr, mailPass, message) => {
         | 
| 2 | 
            +
                const options = {
         | 
| 3 | 
            +
                    from: mailAddr,
         | 
| 4 | 
            +
                    to: mailAddr,
         | 
| 5 | 
            +
                    subject: "Lab05 task #3",
         | 
| 6 | 
            +
                    text: message,
         | 
| 7 | 
            +
                };
         | 
| 8 | 
            +
                const transporter = nodemailer.createTransport({
         | 
| 9 | 
            +
                    host: 'smtp.yandex.com',
         | 
| 10 | 
            +
                    port: 465,
         | 
| 11 | 
            +
                    secure: true,
         | 
| 12 | 
            +
                    auth: {
         | 
| 13 | 
            +
                        user: mailAddr,
         | 
| 14 | 
            +
                        pass: mailPass,
         | 
| 15 | 
            +
                    },
         | 
| 16 | 
            +
                });
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                return new Promise((resolve, reject) => {
         | 
| 19 | 
            +
                    transporter.sendMail(options, (err, info) => {
         | 
| 20 | 
            +
                        if (err) {
         | 
| 21 | 
            +
                            reject(err);
         | 
| 22 | 
            +
                        } else {
         | 
| 23 | 
            +
                            resolve(info);
         | 
| 24 | 
            +
                        }
         | 
| 25 | 
            +
                    });
         | 
| 26 | 
            +
                });
         | 
| 27 | 
            +
            }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            exports.send = send;
         | 
    
        package/package.json
    ADDED
    
    | @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "dependencies": {
         | 
| 3 | 
            +
                "nodemailer": "^6.9.7",
         | 
| 4 | 
            +
                "nodemailer-smtp-transport": "^2.7.4",
         | 
| 5 | 
            +
                "pvg_m06": "^1.0.0"
         | 
| 6 | 
            +
              },
         | 
| 7 | 
            +
              "name": "pvg_m05",
         | 
| 8 | 
            +
              "version": "1.0.0",
         | 
| 9 | 
            +
              "main": "06-03.js",
         | 
| 10 | 
            +
              "scripts": {
         | 
| 11 | 
            +
                "test": "echo \"Error: no test specified\" && exit 1"
         | 
| 12 | 
            +
              },
         | 
| 13 | 
            +
              "author": "",
         | 
| 14 | 
            +
              "license": "ISC",
         | 
| 15 | 
            +
              "description": "\"My first package\"",
         | 
| 16 | 
            +
              "devDependencies": {}
         | 
| 17 | 
            +
            }
         |