-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patholdMailer.js
More file actions
47 lines (41 loc) · 1.41 KB
/
oldMailer.js
File metadata and controls
47 lines (41 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var nodemailer = require('nodemailer');
var ConfigParser = require('./ConfigParser.js');
var Mailer = function (receivers) {
this.receivers = receivers || ConfigParser.getProperties().emailReceivers.toString();
this.smtpConfig = {
host: 'mx3.avia-centr.ru',
port: 25,
secure: false, // use SSL,
tls: {
rejectUnauthorized: false
}
};
var transporter = nodemailer.createTransport(this.smtpConfig);
/*
* input {subject:'',body:''}
*/
this.send = function (email, callback) {
// setup e-mail data with unicode symbols
var body = email.body || '';
var attachments = email.attachments || [];
var mailOptions = {
from: 'tests@avia-centr.ru', // sender address
to: this.receivers, // list of receivers
subject: email.subject,
// text: 'Hello world 🐴', // plaintext body
html: body, // html body
attachments: attachments
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
return console.log(error);
}
console.log('Message sent: ' + info.response);
if (callback) {
callback();
}
});
};
};
module.exports = Mailer;