Disable the sending of the strapi email template while keeping the "confirmationToken" field

System Information
  • Strapi Version: 4.0.7

Hello,

I use sendgrid as email provider, but the strapi email template is also send (reset and confirmation email)…
I have to keep active the “Enable email confirmation” field in settings to keep the confirmationToken for sendGrid.

There is a way to disable default strapi email ?

There is my code:

/src/index.js

module.exports = async () => {
  strapi.db.lifecycles.subscribe({
    models: ["plugin::users-permissions.user"],
    async afterUpdate(event) {
      const { confirmationToken, resetPasswordToken, nom, prenom, email } =
        event.result;

      if (confirmationToken)
        await strapi.plugins["email"].services.email.send({
          to: email,
          from: "my_email",
          template_id: "template_id_from_sendgrid",
          dynamic_template_data: {
            firstname: prenom,
            lastname: nom,
            confirmUrl: `${process.env.API_URL}/auth/email-confirmation?confirmation=${confirmationToken}`,
            supportUrl: `${process.env.APP_URL}/app?contact`,
          },
        });
      else if (resetPasswordToken)
        await strapi.plugins["email"].services.email.send({
          to: email,
          from: "my_email",
          template_id: "template_id_from_sendgrid",
          dynamic_template_data: {
            firstname: prenom,
            lastname: nom,
            resetUrl: `${process.env.APP_URL}/app/reinitialisation?token=${resetPasswordToken}`,
            supportUrl: `${process.env.APP_URL}/app?contact`,
          },
        });
    },
  });
};

Thanks for your help !

did you find a solution?