I have a couple of functions that I created on the server side that I used to send a triggered email to certain users. It was working wonderfully UNTIL I transferred the entire site to a new owner. Previously, the site was under my own name. I have now transferred it to the final owner.
Here’s the story: I have a form that, when submitted, I send a triggered email to a member who is not the current user. I have created a backend function that uses wixUsersBackend.emailUser to send the email.
Here’s the problem: these emails are not being sent out. From the console, I get success, but no emails are sent to this non-current user person UNLESS, when testing, I log into the website and submit the form using my old email address that was used before I transferred the site. In that case, the person who submitted the form gets TWO emails (the correct one plus the one meant for the non-current user). the non-current user gets the correct email. The non-current user never gets an email otherwise.
Here’s my attempts to solve (but failed): Thinking the transfer has done something, I completely recreated the triggered email templates. I have validated all the parameter data sent to wixUsersBackend.emailUser.
I am at a loss. Is there another way to troubleshoot this? I am also running out of time to get this website into production. Please help!
Code snippets:
FORM CODE:
// Send head’s up email to common ARC email address
let templateData = {
firstName: $w( “#firstName” ).value,
lastName: $w( “#lastName” ).value,
prjShortDesc: $w( “#prjShortDesc” ).value
}
eMailARC( “ARCRecieved” ,templateData)
.then (result => {
console.log( "eMailARC results: " + result);
})
BACKEND CODE:
export function eMailARC(template, templateData) {
// get the contact ID of the ARC lead to send the email to.
wixData.query( “Members/PrivateMembersData” )
.eq( “loginEmail” , “xxx@xxx.com” )
.find()
.then( (results) => {
/ /NOTE: I have validated the above query above returns the desired data
wixUsersBackend.emailUser(template, results.items[0].contactId,{
variables: {
firstName: templateData[ “firstName” ],
lastName: templateData[ “lastName” ],
prjShortDesc: templateData[ “prjShortDesc” ]
}
})
.then( () => {
//NOTE: When running in preview, this message is displayed. but no email
console.log( “successfully sent notification email to ARC” );
return “Email Sent”
})
. catch ( (err) => {
return JSON.stringify( "email send error: " + err);
});
})
. catch ( (err) => {
return JSON.stringify( "query error: " + err);
});
}
Thanks!
Steve G.