2021-11-16 07:18:18 +01:00
|
|
|
var nodemailer = require("nodemailer");
|
|
|
|
|
|
|
|
let config;
|
|
|
|
try {
|
|
|
|
config = require('../config');
|
|
|
|
} catch (e) {
|
|
|
|
console.log('No config file found');
|
|
|
|
process.exit(0);
|
|
|
|
}
|
|
|
|
|
2021-11-17 09:32:44 +01:00
|
|
|
function send(to, subject, content) {
|
2021-11-16 07:18:18 +01:00
|
|
|
var email = email;
|
|
|
|
var token = token;
|
|
|
|
var mail = nodemailer.createTransport({
|
|
|
|
host: config.mail.host,
|
|
|
|
port: config.mail.port,
|
|
|
|
secure: false,
|
|
|
|
auth: {
|
|
|
|
user: config.mail.user,
|
|
|
|
pass: config.mail.password,
|
|
|
|
},
|
|
|
|
tls: {
|
|
|
|
rejectUnauthorized: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
var mailOptions = {
|
|
|
|
from: config.mail.user,
|
2021-11-17 09:32:44 +01:00
|
|
|
to: to,
|
|
|
|
subject: subject,
|
|
|
|
html: content
|
2021-11-16 07:18:18 +01:00
|
|
|
};
|
|
|
|
mail.sendMail(mailOptions, function (error, info) {
|
|
|
|
if (error) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
send
|
|
|
|
}
|