m06_kmo 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/m06_KMO.js +29 -0
- package/package.json +11 -0
package/m06_KMO.js
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
const nodemailer = require('nodemailer');
|
2
|
+
const smtpTransport = require('nodemailer-smtp-transport');
|
3
|
+
|
4
|
+
function send(sender, password, receiver, message){
|
5
|
+
let transporter = nodemailer.createTransport(smtpTransport({
|
6
|
+
host: 'smtp.gmail.com',
|
7
|
+
port: 587,
|
8
|
+
secure: false,
|
9
|
+
auth: {
|
10
|
+
user: sender,
|
11
|
+
pass: password
|
12
|
+
}
|
13
|
+
}));
|
14
|
+
|
15
|
+
var mailOptions = {
|
16
|
+
from: sender,
|
17
|
+
to: receiver,
|
18
|
+
subject: 'Lab5',
|
19
|
+
text: message,
|
20
|
+
html: `<i>${message}</i>`,
|
21
|
+
attachments: [{ filename: 'hqdefault.jpg', path: __dirname + '/hqdefault.jpg', cid: 'img' }]
|
22
|
+
};
|
23
|
+
|
24
|
+
transporter.sendMail(mailOptions, function(error, info) {
|
25
|
+
error ? console.log(error) : console.log('Email sent: ' + info.response);
|
26
|
+
})
|
27
|
+
};
|
28
|
+
|
29
|
+
module.exports = send;
|