Register account email validation link

I have tow requests about this subject

  • First i tried to user the strapi endpoint /users to create a public user. It is working but i dont’t know how to send an email validation account with a link to confirme the account creation.
    I did that but no email was send

  • I tried too, to do my own endpoint with my own controller to create a user. It is works and the mail is sent but i don’t know how to get the link (with the token) to active the account to send it to the new user.
    Here is my controller :

Thanks in advance

Hi @Jean1

You can use the built in service to this with strapi.plugins['users-permissions'].services.sendConfirmationEmail()

See the code for the service here:

Hi @DMehaffy thanks for the answer, i’ll try your solution as soon as possible.

1 Like

I suspect you’re using “createUser” instead of “register”. This got me stumped in the beginning.

You will also need to set up some reasonable provider for email. There is a default using the equivalent (if not actual) ‘Sendmail’ - but given there’s no auth, reverse lookups, mx, etc., your email will likely be blocked by most email services. I personally use sendgrid but have also used nodemailer smtp & auth with my email provider (O365).
If you’ve already set up, configured, and using a provider other than the default - then my suspicion will be that you are likely using createUser. If so, switch to using register. Also, don’t forget to enable sending email confirmation in the Admin panel under Advanced Settings.

The mutation required for registering a user:

 mutation register( 
  $username: String!,
  $email: String!,
  $password: String!,
  register (input: { 
    username: $username,
    email: $email,
    password: $password,
  }) {
    user {

* edit was to add the mutation.