mirror of
https://github.com/strapi/strapi.git
synced 2025-07-24 09:25:25 +00:00
33 lines
685 B
JavaScript
33 lines
685 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Email.js controller
|
|
*
|
|
* @description: A set of functions called "actions" of the `email` plugin.
|
|
*/
|
|
module.exports = {
|
|
send: async ctx => {
|
|
// Verify if the file email is enable.
|
|
if (strapi.plugins.email.enabled === false) {
|
|
strapi.log.error('Email is disabled');
|
|
return ctx.badRequest(null, [
|
|
{
|
|
messages: [{ id: 'Email.status.disabled', message: 'Emails disabled' }],
|
|
},
|
|
]);
|
|
}
|
|
|
|
// Something is wrong
|
|
if (ctx.status === 400) {
|
|
return;
|
|
}
|
|
|
|
let options = ctx.request.body;
|
|
|
|
await strapi.plugins.email.services.email.send(options);
|
|
|
|
// Send 200 `ok`
|
|
ctx.send({});
|
|
},
|
|
};
|