rename errorManager, fin forgotpass pai
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
const nodemailer = require('nodemailer');
|
||||
const config = require('../config.json');
|
||||
const util = require('util');
|
||||
|
||||
module.exports = async(toMail, type = 'forgotpass', data = []) => {
|
||||
module.exports = async(toMail, template = {}, data = []) => {
|
||||
let transporter = nodemailer.createTransport({
|
||||
host: config.smtp.host,
|
||||
port: config.smtp.port,
|
||||
@@ -16,9 +17,9 @@ module.exports = async(toMail, type = 'forgotpass', data = []) => {
|
||||
let mailOptions = {
|
||||
from: config.smtp.sys_mail, // sender address
|
||||
to: toMail, // list of receivers
|
||||
subject: 'Hello ✔', // Subject line
|
||||
text: 'Hello world ?', // plain text body
|
||||
html: '<b>Hello world ?</b>' // html body
|
||||
subject: template.title || '', // Subject line
|
||||
text: template.text ? util.format(template.text, ...data) : '', // plain text body
|
||||
html: template.html ? util.format(template.html, ...data) : '' // html body
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -27,7 +28,7 @@ module.exports = async(toMail, type = 'forgotpass', data = []) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
// console.log('Message %s sent: %s', info.messageId, info.response);
|
||||
// console.log('Mepassage %s sent: %s', info.messageId, info.response);
|
||||
return resolve(info);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user