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
Moralis server uses parse server and some functionality is directly from parse server.
I donāt know if you can get the username value in that template. You could add a request on roadmap.moralis.io
i had to make my own function and build the confirmation link by myself. Not sure if this is the best apporach but it is wokring, here is the cloud function iāve put together if someone needs it, you are wellcome.
you need to remove the template id from the serverās settings for verification, this way it doesnāt sent an autmate email each time a user is created in the db, and also you can say āhi nicknameā to your users (something that was not possible with the autmated email)
Moralis.Cloud.define("sendWelcomeEmail", (request) => {
const logger = Moralis.Cloud.getLogger();
const server_url ="https://yourserverurl:2053/server";
const appid ="your_app_id_here";
const algo = JSON.stringify(request.user);
let substring = algo.substring( algo.search("_email_verify_token"), algo.search("_email_verify_token") + 48);
let sub = substring.split(":");
const verify_token = sub[1].replaceAll('"', '');
logger.info("formed link: " + server_url + "/apps/" + appid + "/verify_email?token=" + verify_token +"&username=" + request.params.email);
Moralis.Cloud.sendEmail({
to: request.params.email,
templateId: "d-YOUR_TEMPLATE_ID_HERE",
dynamic_template_data:{name: request.params.name, link: server_url + "/apps/" + appid + "/verify_email?token=" + verify_token +"&username=" + request.params.email},
})
});
Moralis.Cloud.afterSave(Moralis.User, async (request) => {
// code here
return "user updated";
});