mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 00:51:17 +00:00
25 lines
510 B
JavaScript
25 lines
510 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Email.js controller
|
|
*
|
|
* @description: A set of functions called "actions" of the `email` plugin.
|
|
*/
|
|
module.exports = {
|
|
send: async ctx => {
|
|
let options = ctx.request.body;
|
|
try {
|
|
await strapi.plugins.email.services.email.send(options);
|
|
} catch (e) {
|
|
if (e.statusCode === 400) {
|
|
return ctx.badRequest(e.message);
|
|
} else {
|
|
throw new Error(`Couldn't send email: ${e.message}.`);
|
|
}
|
|
}
|
|
|
|
// Send 200 `ok`
|
|
ctx.send({});
|
|
},
|
|
};
|