Really weird problem with emailUser

Hello guys,

My website is like a job board website, with a process that has, no many, but a few steps.
So I used the code “WixUsers.emailUser” to create notifications about the processes.

I get the userid from the privatedatabase and everthing is fine, working very well.

and then, all of the sudden, it stopped working, but thats ok, I just got to figure out whats wrong, right?

So when the code stopped to work, I didn’t simply stopped sending emails. I started sending emails to the wrong address. thats the part I can’t understand.

the code I’m using to test the problem right now is this:

import wixUsers from ‘wix-users’ ;

export function button29_click ( event ) {

let text = “Test”
wixUsers . emailUser ( ‘SaQq1oX’ , “81d8471c-de89-47ef-9c68-453ceff9d5e7” , { variables : { nomedacampanha : test }})
. then ( () => {
console . log ( “email has been sent” )
} )
. catch ( ( err ) => {
console . log ( “there was an error sending the email” )
} );

}

As you can see, the user " 81d8… " is a hotmail account, and the " f483 …" is a Gmail account. I doesn’t matter what user I put in the code, the email will go to the Gmail acount. I’m not saying that the code only workes for the user " f483… ", I’m saying that even if I put the user " 81d8… " the email will STILL GO TO THE GMAIL ACCOUNT, is the freakest thing, I have absolutely no idea of whats going on.

Somebody has any inside about this?

and yes, before anyone asks, I tested with every single person registered as a member, It doesn’t matter, the email always go to the Gmail account registered to the user " f483… "

Thanks in advance.

As the emailUser() API states, " Sends a Triggered Email to the currently logged-in site member. " What that means, is that no matter what userId you provide, the email will go to the currently logged-in site member .

To send emails to specific users, you will need to use the wix-users-backend.emailUser() API which is called from backend code.

Ok, you are not wrong, I tested putting the code in the backend and had EXACTLY the same result. the Email continues to go to the “f483…” user.
But in any case, that can’t be the problem, because I’m not logged as the user “f483…”, and still te email always goes there.

But thanks for the help!

@tallisonxd Are you testing this from Preview or Live? What does your new code look like? How are you calling from the frontend?

@yisrael-wix This is the Backend:

import wixUsersBackend from ‘wix-users-backend’ ;

export function send (){ return wixUsersBackend . emailUser ( ‘SaQq1oX’ , “81d8471c-de89-47ef-9c68-453ceff9d5e7” , { variables : { nomedacampanha : “123” }}). then ( () => { console . log ( “email has been sent” )} ). catch ( ( err ) => { console . log ( “there was an error sending the email” )} );}

This is the front end:
import { send } from “backend/idusuario.jsw”
export function button29_click ( event ) { return send ();}

And I’m testing in both, live and preview.

@tallisonxd You should realize that the wix-users and wix-users-backend APIs are only partially functional in Preview.

@tallisonxd Please post the URL of your site and explain how and where to see the problem.

@yisrael-wix https://www.querouminfluencer.com.br/test-send-email

This is the URL where i’m testing the email thing, I made some changes on the code:

Front-end

import { send } from “backend/idusuario.jsw”

export function button29_click ( event ) {
let user = $w ( “#input1” ). value
let title = $w ( “#input2” ). value
return send ( user , title )
. then ( () => {
console . log ( "email has been sent to " + user + " with the title " + title )
} )
. catch ( ( err ) => {
console . log ( “there was an error sending the email” )
});
}

Backend

export function send ( user , title ){

return wixUsersBackend . emailUser ( ‘SaQq1oX’ , user , { variables : { nomedacampanha : title }})
}

Here it is a video showing how confusing is this error:

I just now realized it’s not only me that is confused, wix itself has no idea whats going on. I went into the Emails infos, to see the stats and such, and notice that the log there is showing the email going to the right place:

But it’s still arriving at the gmail account, WT# is going on?! Did I break wix?

@tallisonxd What’s not clear to me is who are the users. Your test page has two separate (different) users, and that both are you with different emails. Is that correct?

@yisrael-wix Yes thats right, my website is still not ready for lauch, we are adding new features, I have 4 member at the website, this 2 that are me with different accounts (so I can monitor where the emails are going), a Master account, that is the bussines email, and my partner’s account.

I already tested with the 4 emails and the result is always the same, the email goes to my gmail account (tallisonxd@gmail.com), and I have no idea why it goes to that email.

the reason that the test page has only 2 of the 4 users, is becauses it’s easy for me to monitor the 2 emails that are mine, the other 2 I have to get in touch with my partner to get acess to.

@tallisonxd Have you tried to send emails to the other 2 users to see if they work as expected? I’d like to know if things are totally weird, or just a bit. It could be that for some reason the system thinks you are one and the same.

Note: you should be testing this solely in Live mode. In Preview, wix-users and wix-users-backend are only partially functional and will not behave as want or expect. In Preview mode, the user is always you - the admin and site owner.

@yisrael-wix Yes I tried with the other 2 accounts, and it went to (Tallisonxd@gmail.com) just the same.

And yes, after you warned me about the preview mode, i’m now only using in live mode.

Hey Guys!
Just wanted to post some update, I talked with wix support and gave access to my website and apparently this was the problem:


The Gmail found it’s way as a secondary email in all of the registered accounts, I still don’t know how this happened, BUT, it’s solved now.

Thanks @yisrael-wix for all the help!

Wow! What a relief, not just for you, but for me too. I was really starting to feel stupid.

The Customer Care Team is awesome !