rename errorManager, fin forgotpass pai

This commit is contained in:
Jay
2017-06-06 15:04:41 +08:00
parent 60cfc0d97d
commit 298bf45585
6 changed files with 85 additions and 46 deletions
+6 -5
View File
@@ -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);
});
});