diff --git a/ghost/admin/views/debug.js b/ghost/admin/views/debug.js index e08e2b5c8a..e3333a15d4 100644 --- a/ghost/admin/views/debug.js +++ b/ghost/admin/views/debug.js @@ -6,7 +6,8 @@ events: { "click .settings-menu a": "handleMenuClick", "click #startupload": "handleUploadClick", - "click .js-delete": "handleDeleteClick" + "click .js-delete": "handleDeleteClick", + "click #sendtestmail": "handleSendTestMailClick" }, initialize: function () { @@ -154,6 +155,35 @@ } } })); - } + }, + + handleSendTestMailClick: function (ev) { + ev.preventDefault(); + + $.ajax({ + url: Ghost.paths.apiRoot + '/mail/test/', + type: 'POST', + headers: { + 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content') + }, + success: function onSuccess(response) { + Ghost.notifications.addItem({ + type: 'success', + message: ['Check your email for the test message: ', response.message].join(''), + status: 'passive' + }); + }, + error: function onError(response) { + var responseText = JSON.parse(response.responseText), + message = responseText && responseText.error ? responseText.error : 'unknown'; + Ghost.notifications.addItem({ + type: 'error', + message: ['A problem was encountered while sending the test email: ', message].join(''), + status: 'passive' + }); + + } + }); + }, }); }());