sendmessageshum 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/06-04.js +8 -0
- package/package.json +14 -0
- package/send.js +26 -0
package/06-04.js
ADDED
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;
|