m06_kmo 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/m06_KMO.js +29 -0
  2. 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;
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "m06_kmo",
3
+ "version": "1.0.1",
4
+ "description": "send message",
5
+ "main": "m06_KMO.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC"
11
+ }