Overriding sendConfirmationEmail method in Strapi V4


To override the sendConfirmationEmail function in Strapi, you can use the concept of extensions. Here are the steps:

  1. Copy the User.js file from ./node_modules/strapi-plugin-users-permissions/services/ to ./extensions/users-permissions/services/.

  2. In the copied User.js file, remove all the unused functions and modify the sendConfirmationEmail function as per your requirements.

Here is an example of how your User.js file might look after modification:

'use strict';

const crypto = require('crypto');
const { sanitizeEntity, getAbsoluteServerUrl } = require('strapi-utils');

module.exports = {
  async sendConfirmationEmail(user) {
    // Your custom logic here...
  },
};

Please note that you should be careful when using extensions and upgrading your Strapi version, as mentioned in the Strapi documentation (https://strapi.io/documentation/developer-docs/latest/concepts/customization.html#plugin-extensions).

Sources:


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: