sendmessageshum 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/06-04.js +8 -0
  2. package/package.json +14 -0
  3. package/send.js +26 -0
package/06-04.js ADDED
@@ -0,0 +1,8 @@
1
+ const {send} = require("06-04");
2
+ const http = require("http");
3
+
4
+ http.createServer((req, res) => {
5
+ let message = "Hello!"
6
+ send("nodelabsbstu@yandex.ru",message);
7
+ res.end(`<h1>${message}</h1>`)
8
+ }).listen(5000);
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "sendmessageshum",
3
+ "version": "1.0.0",
4
+ "main": "06-04.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "author": "",
9
+ "license": "ISC",
10
+ "dependencies": {
11
+ "06-04": "^1.0.0"
12
+ },
13
+ "description": ""
14
+ }
package/send.js ADDED
@@ -0,0 +1,26 @@
1
+ const nodemailer = require('nodemailer');
2
+ const smtpTransport = require("nodemailer-smtp-transport");
3
+
4
+ function sendMessage(sender,receiver, subject, message, password) {
5
+ const transporter = nodemailer.createTransport(smtpTransport({
6
+
7
+ host: 'smtp.yandex.ru',
8
+ port: 465,
9
+ secure: true,
10
+ auth: {
11
+ user: sender,
12
+ pass: password
13
+ }
14
+ }));
15
+
16
+ const mailOption = {
17
+ from: sender,
18
+ to: receiver,
19
+ subject: subject,
20
+ text: message,
21
+ html: `<h1>${message}</h1>`
22
+ }
23
+ transporter.sendMail(mailOption)
24
+ }
25
+
26
+ module.exports = sendMessage;