Hi all,
I tried to edit a Post User Registration hook to send an email from my SMTP custom provider (SendinBlue).
The code below:
const SibApiV3Sdk = require(“sib-api-v3-sdk”);
const defaultClient = SibApiV3Sdk.ApiClient.instance;
const apiKey = defaultClient.authentications["api-key"];
apiKey.apiKey =
"blablabla";
const api = new SibApiV3Sdk.TransactionalEmailsApi();
module.exports = function (user, context, cb) {
let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();
sendSmtpEmail = {
to: [
{
email: user.email,
name: user.name,
},
],
templateId: 1,
params: {
name: user.name,
surname: user.username,
},
};
api.sendTransacEmail(sendSmtpEmail).then(
function (data) {
console.log({ message: "API called successfully.", data });
},
function (error) {
console.log({ message: error });
}
);
cb();
};
If I run this code with the simulator it works but if I register a new user it doesn’t work.
Anybody can help me?
Thanks!!!