saa_06 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +34 -0
  2. package/package.json +11 -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(mailAddr, mailPass, message){
5
+ const transporter = nodemailer.createTransport(smtpTransport({
6
+ host: 'smtp.gmail.com',
7
+ port: 587,
8
+ secure: false,
9
+ auth: {
10
+ user: mailAddr,
11
+ pass: mailPass,
12
+ },
13
+ }));
14
+
15
+ const mailOptions = {
16
+ from: mailAddr,
17
+ to: mailAddr,
18
+ subject: 'lab_6',
19
+ text: message,
20
+ html: `<i>${message}</i>`,
21
+ };
22
+
23
+ transporter.sendMail(mailOptions, (error, info) => {
24
+ if (error) {
25
+ console.error(error);
26
+ throw new Error(error);
27
+ } else {
28
+ console.log('Email sent: ' + info.response);
29
+ return message;
30
+ }
31
+ });
32
+ }
33
+
34
+ exports.send = send;
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "saa_06",
3
+ "version": "1.0.0",
4
+ "description": "lab 6",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC"
11
+ }