Node.js based forum software built for the modern web
logic for #1837
Julian Lam89a9d4b7f2c9
diff --git a/public/language/en_GB/email.json b/public/language/en_GB/email.jsonindex 687b18503c..87d3a5be39 100644--- a/public/language/en_GB/email.json+++ b/public/language/en_GB/email.json@@ -20,5 +20,7 @@"digest.unsub.cta": "Click here to alter those settings","digest.daily.no_topics": "There have been no active topics in the past day",+ "test.text1": "This is a test email to verify that the emailer is set up correctly for your NodeBB.",+"closing": "Thanks!"}\ No newline at end of filediff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.jsonindex 79a26a9aa5..2b9a0aec46 100644--- a/public/language/en_GB/error.json+++ b/public/language/en_GB/error.json@@ -33,6 +33,7 @@"no-user": "User doesn't exist","no-teaser": "Teaser doesn't exist","no-privileges": "You don't have enough privileges for this action.",+ "no-emailers-configured": "No email plugins were loaded, so a test email could not be sent","category-disabled": "Category disabled",diff --git a/public/src/forum/admin/settings.js b/public/src/forum/admin/settings.jsindex c43ccc5c35..8cb6ebfdae 100644--- a/public/src/forum/admin/settings.js+++ b/public/src/forum/admin/settings.js@@ -91,12 +91,24 @@ define('forum/admin/settings', ['uploader', 'sounds'], function(uploader, soundshandleUploads();- $('#settings-tab a').click(function (e) {+ $('#settings-tab a').off('click').on('click', function (e) {e.preventDefault();$(this).tab('show');return false;});+ $('button[data-action="email.test"]').off('click').on('click', function() {+ socket.emit('admin.email.test', function(err) {+ app.alert({+ alert_id: 'test_email_sent',+ type: !err ? 'info' : 'danger',+ title: 'Test Email Sent',+ message: err ? err.message : '',+ timeout: 2500+ });+ });+ });+if (typeof callback === 'function') {callback();}diff --git a/src/socket.io/admin.js b/src/socket.io/admin.jsindex 9f6a0be04b..44bb228ade 100644--- a/src/socket.io/admin.js+++ b/src/socket.io/admin.js@@ -9,6 +9,7 @@ var groups = require('../groups'),categories = require('../categories'),logger = require('../logger'),events = require('../events'),+ emailer = require('../emailer'),db = require('../database'),async = require('async'),winston = require('winston'),@@ -22,7 +23,8 @@ var groups = require('../groups'),plugins: {},widgets: {},config: {},- settings: {}+ settings: {},+ email: {}};SocketAdmin.before = function(socket, method, next) {@@ -121,4 +123,16 @@ SocketAdmin.settings.set = function(socket, data, callback) {meta.settings.set(data.hash, data.values, callback);};+SocketAdmin.email.test = function(socket, data, callback) {+ if (plugins.hasListeners('action:email.send')) {+ emailer.send('test', socket.uid, {+ subject: '[NodeBB] Test Email',+ site_title: meta.config.site_title || 'NodeBB'+ });+ callback();+ } else {+ callback(new Error('[[error:no-emailers-configured]]'));+ }+};+module.exports = SocketAdmin;