mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
fixes to emailing errors
This commit is contained in:
parent
08f4d5fe20
commit
5cb6e7e0dd
3 changed files with 12 additions and 40 deletions
|
|
@ -7,6 +7,7 @@
|
|||
"NODE_DB_URI":"mongodb://localhost/habitrpg",
|
||||
"NODE_ENV":"development",
|
||||
"SESSION_SECRET":"YOUR SECRET HERE",
|
||||
"ADMIN_EMAIL": "you@yours.com",
|
||||
"SMTP_USER":"user@domain.com",
|
||||
"SMTP_PASS":"password",
|
||||
"SMTP_SERVICE":"Gmail",
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
var nconf = require('nconf');
|
||||
|
||||
process.on("uncaughtException", function(error) {
|
||||
var sendEmail;
|
||||
sendEmail = function(mailData) {
|
||||
var nodemailer, smtpTransport;
|
||||
nodemailer = require("derby-auth/node_modules/nodemailer");
|
||||
/* create reusable transport method (opens pool of SMTP connections)*/
|
||||
|
||||
/* TODO derby-auth isn't currently configurable here, if you need customizations please send pull request*/
|
||||
|
||||
smtpTransport = nodemailer.createTransport("SMTP", {
|
||||
service: nconf.get('SMTP_SERVICE'),
|
||||
auth: {
|
||||
user: nconf.get('SMTP_USER'),
|
||||
pass: nconf.get('SMTP_PASS')
|
||||
}
|
||||
});
|
||||
/* send mail with defined transport object*/
|
||||
|
||||
return smtpTransport.sendMail(mailData, function(error, response) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
console.log("Message sent: " + response.message);
|
||||
}
|
||||
/* shut down the connection pool, no more messages*/
|
||||
|
||||
return smtpTransport.close();
|
||||
});
|
||||
};
|
||||
sendEmail({
|
||||
from: "HabitRPG <admin@habitrpg.com>",
|
||||
to: "tylerrenelle@gmail.com",
|
||||
subject: "HabitRPG Error",
|
||||
text: error.stack
|
||||
});
|
||||
return console.log(error.stack);
|
||||
});
|
||||
|
|
@ -5,13 +5,23 @@ var http = require("http");
|
|||
var path = require("path");
|
||||
var app = express();
|
||||
var nconf = require('nconf');
|
||||
var utils = require('./utils');
|
||||
var middleware = require('./middleware');
|
||||
var server;
|
||||
var TWO_WEEKS = 1000 * 60 * 60 * 24 * 14;
|
||||
|
||||
// ------------ Setup configurations ------------
|
||||
require('./config');
|
||||
require('./errors');
|
||||
process.on("uncaughtException", function(error) {
|
||||
// when we hit an error, send it to admin as an email. If no ADMIN_EMAIL is present, just send it to yourself (SMTP_USER)
|
||||
utils.sendEmail({
|
||||
from: "HabitRPG <" + nconf.get('SMTP_USER') + ">",
|
||||
to: nconf.get('ADMIN_EMAIL') || nconf.get('SMTP_USER'),
|
||||
subject: "HabitRPG Error",
|
||||
text: error.stack
|
||||
});
|
||||
console.error(error.stack);
|
||||
});
|
||||
|
||||
// ------------ MongoDB Configuration ------------
|
||||
mongoose = require('mongoose');
|
||||
|
|
|
|||
Loading…
Reference in a new issue