m0611 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/m06.js +29 -0
- package/package.json +11 -0
package/m06.js
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
const nodemailer = require('nodemailer');
|
2
|
+
const smtpTransport = require('nodemailer-smtp-transport');
|
3
|
+
|
4
|
+
let sender = 'nilladarvin@gmail.com';
|
5
|
+
let receiver = 'nilladarvin@gmail.com';
|
6
|
+
|
7
|
+
module.exports.send = function (message) {
|
8
|
+
let transporter = nodemailer.createTransport(smtpTransport({
|
9
|
+
host: 'smtp.gmail.com',
|
10
|
+
port: 465,
|
11
|
+
service: 'gmail',
|
12
|
+
secure: false,
|
13
|
+
auth: {
|
14
|
+
user: sender,
|
15
|
+
pass: 'xylahhpdwgzehfog'
|
16
|
+
}
|
17
|
+
}));
|
18
|
+
|
19
|
+
var mailOptions = {
|
20
|
+
from: sender,
|
21
|
+
to: receiver,
|
22
|
+
subject: 'lab 5',
|
23
|
+
text: `Message info:${new Date().toLocaleString()}\nMessage:\n${message}`
|
24
|
+
};
|
25
|
+
|
26
|
+
transporter.sendMail(mailOptions, function (error, info) {
|
27
|
+
error ? console.log(error) : console.log('Email sent: ' + info.response);
|
28
|
+
})
|
29
|
+
};
|