Hello there. I used an example found in the web on how to register a user using an email for confirmation. The first part of this procedure concerns the creation of a contact, the creation of a token and the sending of a triggered email to the contact. This is the function that exists in the backend.
export async function approveBy3rdParty(contactInfo) {
const contactId = await wixCrmBackend.createContact({ "emails": [`${contactInfo.email}`] });
console.log("Contact created id: " + contactId);
const tokenForEmail = await createToken(contactInfo, contactId);
console.log("Token ready for email: " + tokenForEmail);
await sendEmailVerification(contactId, tokenForEmail);
}
The code for the sendEmailVerification function is seen below:
import wixCrmBackend from 'wix-crm-backend';
const verificationEmailId = 'register';
export function sendEmailVerification(contactId, approvalToken) {
const obj = {
'url': `https://elianagiak.wixsite.com/e-menus/approve?tokenRegister=${approvalToken}`
}
console.log("Before sendEmailFunction");
sendEmail(verificationEmailId, contactId, obj);
}
Finally, here is the code of sendEmail function:
function sendEmail(emailId, contactId, obj) {
try {
wixCrmBackend.emailContact(emailId, contactId, {
"variables": obj
})
.then(() => {
console.log('email sent successfully');
const options = {
"deleteMembers": true
};
wixCrmBackend.deleteContact(contactId, options)
.then( () => {
console.log('contact was successfully deleted');
})
.catch( (err)=> {
console.log('Error in deleting contact: ', err.toString());
});
})
.catch((err) => {
console.log('err in sendEmail is ', err.toString());
});
} catch (err) {
console.log("err", err.toString())
}
}
I also used an async version of the function:
async function sendEmail(emailId, contactId, obj) {
try {
console.log("Email id: " + emailId + " ContactId: " + contactId + " variables: " + obj.url);
await wixCrmBackend.emailContact(emailId, contactId, {
"variables": obj
});
console.log('email sent successfully');
const options = {
"deleteMembers": true
};
await wixCrmBackend.deleteContact(contactId, options);
console.log('contact with contact id ' + contactId + ' was successfully deleted');
} catch (err) {
console.log("err", err.toString())
}
}
The problem is that a few days ago I was receiving these emails (some times the email was sent but it was not received which was awkward since I did not receive any error on the site monitoring).
However, for the last two days, any email I use to test this code (any email used for registration), results in successful sending of the triggered email (according to site monitoring) while at the same time the email cannot be found neither on the inbox, nor in junk or any other folder.
It is very important to solve this issue since I already paid for a premium site and the above mentioned procedure is related to the registration of any clients I am expecting to have.
Thanks for your time,
George Louloudis
P.S: I also include a screenshot of the triggered email just to be sure I am using the correct code