sendinblue-simple-client
v3.0.0
Published
To install you only need to:
Downloads
13
Readme
SendinBlue Simplified Client
To install you only need to:
yarn add sendinblue-simple-client
Example of usage:
import ClientSendingBlue, { EmailUser } from 'sendinblue-simple-client';
const mySecretApiKey = process.env.API_KEY;
async function main() {
const emailClient: ClientSendingBlue = new ClientSendingBlue(mySecretApiKey);
const sender: EmailUser = {
name: 'dotnotreply',
email: '[email protected]',
};
const destination: EmailUser = {
name: 'John',
email: '[email protected]',
};
const content = await emailClient.templatesProvider(3);
if (content) {
try {
const responseOfContent = await emailClient.sendEmail({
sender: sender,
to: [destination],
subject: '[SUBJECT-here] MY Subject',
content: content,
contentParams: {
name: 'John Doe',
someOtherParam: '123123',
},
});
// or send using a template Id
const responseOfsendByTemplateId =
await emailClient.sendEmailWithTemplateById({
sender: sender,
to: [destination],
subject: '[SUBJECT-here] MY Subject',
contentParams: {
name: 'John Doe',
someOtherParam: '123123',
},
templateId: 1,
});
console.log({ responseOfContent, responseOfsendByTemplateId });
} catch (error) {
console.log(error);
}
}
}
main();