m05_piaa 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/m05_piaa.js +37 -0
  2. package/package.json +17 -0
package/m05_piaa.js ADDED
@@ -0,0 +1,37 @@
1
+ const nodemailer = require('nodemailer');
2
+ const smtpTransport = require('nodemailer-smtp-transport');
3
+
4
+
5
+ function send(sender, receiver, pass, message) {
6
+ let transporter = nodemailer.createTransport(smtpTransport({
7
+ host: 'smtp.gmail.com',
8
+ port: 587,
9
+ secure: false,
10
+ auth: {
11
+ user: sender,
12
+ pass: pass
13
+ }
14
+ }));
15
+
16
+ var mailOptions = {
17
+ from: sender,
18
+ to: receiver,
19
+ subject: 'Lab5',
20
+ text: message,
21
+ html: `<i>${message}</i>`
22
+ //attachments:[{filename:`cat.jpg`, path __dirname + `/имя.jpg`, cid: `img`}]
23
+ };
24
+
25
+ transporter.sendMail(mailOptions, function (error, info){
26
+ if (error)
27
+ {
28
+ console.error(error);
29
+ }
30
+ else
31
+ {
32
+ console.log('Email sent: ' + info.response);
33
+ }
34
+ });
35
+ }
36
+
37
+ module.exports = { send };
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "m05_piaa",
3
+ "version": "1.0.1",
4
+ "description": "",
5
+ "main": "m05_piaa.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "Piasetsky Ilya",
11
+ "license": "ISC",
12
+
13
+ "dependencies": {
14
+ "nodemailer": "^6.9.6",
15
+ "nodemailer-smtp-transport": "^2.7.4"
16
+ }
17
+ }