mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Merge pull request #3129 from jaswilli/issue-3071
Fix mail test send endpoint
This commit is contained in:
commit
1b21a42b48
2 changed files with 17 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
// # Mail API
|
// # Mail API
|
||||||
// API for sending Mail
|
// API for sending Mail
|
||||||
var when = require("when"),
|
var when = require('when'),
|
||||||
config = require('../config'),
|
config = require('../config'),
|
||||||
errors = require('../errors'),
|
errors = require('../errors'),
|
||||||
mail;
|
mail;
|
||||||
|
@ -39,14 +39,16 @@ mail = {
|
||||||
return when.reject(new errors.EmailError(error.message));
|
return when.reject(new errors.EmailError(error.message));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ### SendTest
|
* ### SendTest
|
||||||
* Send a test email
|
* Send a test email
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
|
* @param {Object} required property 'to' which contains the recipient address
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
sendTest: function () {
|
sendTest: function (object) {
|
||||||
var html = '<p><strong>Hello there!</strong></p>' +
|
var html = '<p><strong>Hello there!</strong></p>' +
|
||||||
'<p>Excellent!' +
|
'<p>Excellent!' +
|
||||||
' You\'ve successfully setup your email config for your Ghost blog over on ' + config().url + '</p>' +
|
' You\'ve successfully setup your email config for your Ghost blog over on ' + config().url + '</p>' +
|
||||||
|
@ -57,6 +59,7 @@ mail = {
|
||||||
|
|
||||||
payload = {mail: [{
|
payload = {mail: [{
|
||||||
message: {
|
message: {
|
||||||
|
to: object.to,
|
||||||
subject: 'Test Ghost Email',
|
subject: 'Test Ghost Email',
|
||||||
html: html
|
html: html
|
||||||
}
|
}
|
||||||
|
@ -65,4 +68,5 @@ mail = {
|
||||||
return mail.send(payload);
|
return mail.send(payload);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = mail;
|
module.exports = mail;
|
|
@ -39,7 +39,17 @@ apiRoutes = function (middleware) {
|
||||||
router['delete']('/ghost/api/v0.1/db/', api.http(api.db.deleteAllContent));
|
router['delete']('/ghost/api/v0.1/db/', api.http(api.db.deleteAllContent));
|
||||||
// ## Mail
|
// ## Mail
|
||||||
router.post('/ghost/api/v0.1/mail', api.http(api.mail.send));
|
router.post('/ghost/api/v0.1/mail', api.http(api.mail.send));
|
||||||
router.post('/ghost/api/v0.1/mail/test', api.http(api.mail.sendTest));
|
router.post('/ghost/api/v0.1/mail/test', function (req, res) {
|
||||||
|
api.settings.read('email').then(function (result) {
|
||||||
|
// attach the to: address to the request body so that it is available
|
||||||
|
// to the http api handler
|
||||||
|
req.body = { to: result.settings[0].value };
|
||||||
|
|
||||||
|
api.http(api.mail.sendTest)(req, res);
|
||||||
|
}).catch(function () {
|
||||||
|
api.http(api.mail.sendTest)(req, res);
|
||||||
|
});
|
||||||
|
});
|
||||||
// ## Slugs
|
// ## Slugs
|
||||||
router.get('/ghost/api/v0.1/slugs/:type/:name', api.http(api.slugs.generate));
|
router.get('/ghost/api/v0.1/slugs/:type/:name', api.http(api.slugs.generate));
|
||||||
// ## Authentication
|
// ## Authentication
|
||||||
|
|
Loading…
Add table
Reference in a new issue