const nodemailer = require("nodemailer"); const Config = require('./config'); class MailSystem { constructor() { this.transporter = nodemailer.createTransport({ host: Config.MAIL_HOST, port: Config.MAIL_PORT, secure: Config.MAIL_SECURE, // true for 465, false for other ports auth: Config.MAIL_AUTH, tls: { rejectUnauthorized: false } }); } send(recipient, subject, text, html) { // send mail with defined transport object console.log(html) return this.transporter.sendMail({ from: Config.MAIL_SENDER, // sender address to: recipient, // list of receivers subject: subject, // Subject line //text: text, // plain text body html: html // html body }) //.then(console.log).catch(console.log); } } module.exports = new MailSystem();