@fedosdekudrille/m05_kfa 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +34 -0
- package/package.json +16 -0
package/index.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
const nodemailer = require('nodemailer');
|
2
|
+
const smtpTransport = require('nodemailer-smtp-transport');
|
3
|
+
|
4
|
+
function send(from, to, pass, message) {
|
5
|
+
let transporter = nodemailer.createTransport(
|
6
|
+
smtpTransport({
|
7
|
+
host: 'smtp.mail.ru',
|
8
|
+
port: 587,
|
9
|
+
secure: false,
|
10
|
+
auth: {
|
11
|
+
user: from,
|
12
|
+
pass: pass,
|
13
|
+
},
|
14
|
+
})
|
15
|
+
);
|
16
|
+
|
17
|
+
var mailOptions = {
|
18
|
+
from: from,
|
19
|
+
to: to,
|
20
|
+
subject: 'Lab5',
|
21
|
+
text: message,
|
22
|
+
html: `<i>${message}</i>`,
|
23
|
+
};
|
24
|
+
|
25
|
+
transporter.sendMail(mailOptions, function (error, info) {
|
26
|
+
if (error) {
|
27
|
+
console.error(error);
|
28
|
+
} else {
|
29
|
+
console.log('Email sent: ' + info.response);
|
30
|
+
}
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
module.exports = { send };
|
package/package.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"name": "@fedosdekudrille/m05_kfa",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8
|
+
},
|
9
|
+
"keywords": [],
|
10
|
+
"author": "fedosdekudrille",
|
11
|
+
"license": "ISC",
|
12
|
+
"dependencies": {
|
13
|
+
"nodemailer": "^6.9.6",
|
14
|
+
"nodemailer-smtp-transport": "^2.7.4"
|
15
|
+
}
|
16
|
+
}
|