Closed s4malve closed 2 years ago
Hi @s4malve
Please try the code below:
let defaultClient = SibApiV3Sdk.ApiClient.instance;
let apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = `YOUR_API_KEY`;
let apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();
sendSmtpEmail.subject = "My {{params.subject}}";
sendSmtpEmail.htmlContent = "<html><body><h1>Hey! \n This is my first transactional email {{params.parameter}}</h1></body></html>";
sendSmtpEmail.sender = {"name":"John Doe","email":"example@example.com"};
sendSmtpEmail.to = [{"email":"shubham.upadhyay@sendinblue.com","name":"Jane Doe"}];
sendSmtpEmail.replyTo = {"email":"replyto@domain.com","name":"John Doe"};
sendSmtpEmail.headers = {"Some-Custom-Name":"unique-id-1234"};
sendSmtpEmail.params = {"parameter":"My param value","subject":"New Subject"};
apiInstance.sendTransacEmail(sendSmtpEmail).then(function(data) {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}, function(error) {
console.error(error);
});
Reference for the endpoint: https://developers.sendinblue.com/reference/sendtransacemail
Happy to help!
Please don't forget to add your account YOUR_API_KEY in the placeholder in the script above.
thanks
I was trying to send a mail from an astro endpoint and when i made the request the server send me
Cannot read properties of undefined (reading 'body')
but still sending the email.I followed the Send transactional email api and i dont know what i'm doing wrong