How to send mail automatically after create/publish content?

Is it possible to send mails after you create a content?

module.exports = {
    lifecycles: {
      async afterCreate(result, data) {
        await strapi.plugins["email"].services.email.send({
          to: 'name@domain',
          from: "robot@strapi.io",
          subject: "New message from contact form",
          text: `You can also check it out in Messages section of admin area.`,
        });
      },
    },
  };

This is my setup in src/api/formulario keeping in mind that formulario is my content collection type.

But doesnt work for now.

1 Like

Trying to do the same