mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
* Bump version to 0.0.5-alpha
* Add email password reset support
This commit is contained in:
parent
97e19957ce
commit
f5899bc10f
18 changed files with 571 additions and 28 deletions
31
core/email.js
Normal file
31
core/email.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
const Config = require('./config.js').config;
|
||||
const Errors = require('./enig_error.js').Errors;
|
||||
const Log = require('./logger.js').log;
|
||||
|
||||
// deps
|
||||
const _ = require('lodash');
|
||||
const nodeMailer = require('nodemailer');
|
||||
|
||||
exports.sendMail = sendMail;
|
||||
|
||||
function sendMail(message, cb) {
|
||||
if(!_.has(Config, 'email.transport')) {
|
||||
return cb(Errors.MissingConfig('Email "email::transport" configuration missing'));
|
||||
}
|
||||
|
||||
message.from = message.from || Config.email.defaultFrom;
|
||||
|
||||
const transportOptions = Object.assign( {}, Config.email.transport, {
|
||||
logger : Log,
|
||||
});
|
||||
|
||||
const transport = nodeMailer.createTransport(transportOptions);
|
||||
|
||||
transport.sendMail(message, (err, info) => {
|
||||
return cb(err, info);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue