Regarding email confirmation with backend user.

Hello, I’m trying to send an email to members to verify their emails, so i used the code in the documentation
Here’s my code
For backend/register
files : register.jsw

import wixUsers from 'wix-users-backend';

export function doRegistration(email, password, firstName, lastName) {
 // register the user
 return wixUsers.register(email, password, {
 "contactInfo": {
 "firstName": firstName,
 "lastName": lastName
    }
  } )
  .then( (results) => {
 // user is now registered and pending approval
 // send a registration verification email
    wixUsers.emailUser('RVEq575', results.user.id.user.id, {
 "variables": {
 "name": firstName,
 "verifyLink": `https://www.bella-oro.com/confirmation-d-inscription?token=${results.approvalToken}`
      }
    } );
  } );
}

export function doApproval(token) {
 // approve the user
 return wixUsers.approveByToken(token)
 // user is now active, but not logged in
 // return the session token to log in the user client-side
    .then( (sessionToken) => {
 return {sessionToken, "approved": true};
    } )
    .catch( (error) => {
 return {"approved": false, "reason": error};
    } );
}

in my register page

import {doRegistration} from 'backend/register';
export function register_click(event) {

  $w("#erreurinscripition").hide();
      $w("#text45").hide();
 
 var motdepasse1 = $w('#password').value; 
var motdepasse2 = $w('#password2').value; 
if((motdepasse<4) && (motdepasse1===motdepasse2) && ($w('#email').valid===true)){
 
        $w("#image1").show("fade"); 
 
 let email = $w('#email').value; 
 let password = $w('#password').value;   
 let firstName = $w('#firstName').value; 
 let lastName = $w('#lastName').value; 
 let phone = $w('#mainPhone').value; 
 let nickname = $w('#nickname').value;
 
    doRegistration(email, password, firstName, lastName)
.then( () => {
console.log("Confirmation email sent.");
} );

        }
 
}

And the confirmation page

import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
import {doApproval} from 'backend/register';

$w.onReady( () => {
// get the token from the URL
let token = wixLocation.query.token;
doApproval(token)
.then( (result) => {
if (result.approved){
// log the user in
wixUsers.applySessionToken(result.sessionToken);
console.log("Approved");
}
else {
console.log("Not approved!");
}
} );
} );

I can’t seem to find what i did wrong, the user gets registered but the verification email is not send :confused:

Make sure that you have used all of the code for the client side registration code

/*********************************
* client-side registration code *
*********************************/

import wixUsers from 'wix-users';
import {doRegistration} from 'backend/register';

export function button_click(event) {
let email = // the user's email address
let password = // the user's password
let firstName = // the user's first name
let lastName = // the user's last name

doRegistration(email, password, firstName, lastName)
.then( () => {
console.log("Confirmation email sent.");
} );
}

Also, add a space underneath your imports and then add a onReady function for your page

Finally, I would also just try copying and pasting the code as it is in the example with the verify email set as it is shown in the code example already.
wixUsers.emailUser(‘verifyRegistration’, results.user.id, {

Just so that it doesn’t already send a standard triggered email that is already setup automatically by Wix and to test if it works on your website as it is originally set out.

Finally, if you had your triggered email called ‘verifyRegistration’ too, then in theory you wouldn’t have had to change the code there, just makes it simpler and quicker to do.

I did not provide all my codes, is that good

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window'; 
import {doRegistration} from 'backend/register';
let erreur2=0;
let motdepasse=0;
let fadeOptions = {
 "duration":   300,
 "delay":      2000
};


$w.onReady(function(){  
 

    $w("#text40").hide();
 $w("#text41").hide();
 $w("#text42").hide();
  $w("#text43").hide();
  $w("#text45").hide();
 $w("#password2").hide();
    $w("#erreurinscripition").hide();
     $w("#image1").hide(); 

 


   })


export function register_click(event) {


  $w("#erreurinscripition").hide();
      $w("#text45").hide();
 
 var motdepasse1 = $w('#password').value; 
var motdepasse2 = $w('#password2').value; 

 
        $w("#image1").show("fade"); 
 
 let email = $w('#email').value; 
 let password = $w('#password').value;   
 let firstName = $w('#firstName').value; 
 let lastName = $w('#lastName').value; 
 let phone = $w('#mainPhone').value; 
 let nickname = $w('#nickname').value;
 
    doRegistration(email, password, firstName, lastName)

.then( () => {
 
console.log("Confirmation email sent.");
} );

        }
 



And when i go in preview mode, i don’t see
“Confirmation email sent.”
so there must be something wrong in the client side