Ok I see
how can I confirm that it doesnāt work?
I tried to do that before, I put the id of the template there and I successfully got an email, but with no verification link. I think I need to add the link, but I donāt know how I can get it and where I need to add it.
Your template should have two curly brackets with variable link in it -
Hi {{name}} {{link}}
The values will get prepopulated accordingly.
Hi Malik,
I have tried that and I only get the text I input i.e: "Hi ", I know that I need to define the name to get text there, but I canāt define the link. I cannot find any variables in the template, I tried to put the variables in the Design Editor ācodeā and ātextā and Code Editor.
Maybe there is something Iām doing wrong?
How does your template look like now?
Maybe Iām doing it wrong, but I donāt understand how I can make the verification link work
I just checked my templates and I have this: Hello {{{ link }}} {{{ email }}}
Ok I see, I changed it like yours: Verify your email {{{ link }}}
and in my cloud function it looks like this:
Moralis.Cloud.define("sendVerification", async (request) => {
Moralis.Cloud.sendEmail({
to: request.user.get("email"),
templateId: "d-0c47c30df8d945c0bf6ae1db793d8702",
dynamic_template_data: {
link: Moralis.User.requestEmailVerification(request.user.get("email"))
}
});
});
I tried to set the link
variable to requestEmailVerification()
and it worked!
but I get 2 emails, one with the link and the other with map[]
If the email is already verified I only get an email with map[]
If I didnāt set the variable link
to anything I would get an email with āVerify your emailā like before
It also gets set to true in the dashboard
Any idea why I get two emails?
I think that it is enough to use Moralis.User.requestEmailVerification(request.user.get("email"))
in order to send an email.
I changed it and now I only get one email! I defined the userEmail
in the frontend and passed it to the cloud function call.
const currentUser = Moralis.User.current();
const userEmail = currentUser.attribute.email;
await Moralis.Cloud.run("sendVerification", {userEmail});
and in the cloud function I added userEmail and requestEmailVerification(userEmail)
Moralis.Cloud.define("sendVerification", async (request) => {
Moralis.Cloud.sendEmail({
to: request.user.get("email"),
templateId: "d-0c47c30df8d945c0bf6ae1db793d8702",
dynamic_template_data: {
userEmail: request.user.get("email"),
link: Moralis.User.requestEmailVerification(userEmail)
}
});
});
Thank you very much for the help guys! I really appreciate it
Oh ok, so you mean that I donāt need to set the variable link
?
I think that you only have to call Moralis.User.requestEmailVerification(userEmail)
from front end.
Ok thanks, now I added it to the frontend, saved it in a variable, and passed it to the cloud function call.
const emailVerification = await Moralis.User.requestEmailVerification(userEmail);
await Moralis.Cloud.run("sendVerification", {userEmail, emailVerification});
and I changed link: emailVerification,
in the cloud function. It works but I get the email only one time, if I have not verified the email and then login again later I wonāt get any other verification email.
Is it supposed to be like that?
I think that this is all you need to do:
const emailVerification = await Moralis.User.requestEmailVerification(userEmail);
without any other cloud function.
and this email will be sent automatically by Moralis when a new user gets registered with an email, or if you add an email to a user entry from the dashboard.
this is so frustratingā¦ i have been 4 hours trying to send ONLY one email and not only with the verification link but with the userās name as follow āHello USERNAMEā but I canāt find how to. Also there is no documentation whatsoever for this function Moralis.User.requestEmailVerification(email);
what were you able to do? were you able to change the static text in the template?
found this on google in case that helps you:
https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#.requestEmailVerification
I was able to use this syntax in a template: {{{ link }}} {{{ email }}}
wow, what is that link? i thought requestemailverification was a moralis function. is not?
i just want to be able to send confimration email by myself and not to be sent autmatically by the server each time a user registers, if i set sendgrid template id in the server, then it sends the email by itself!!! 'and i am not being able to say āhello USERā with the userās name.
this two works but with out a pair of { I think you have them wrong: {{ link }}} {{{ email }}} but {{user}} or {{username}} or {{first_name}} as I have them in my database, DONT WORK