@auronet/sendinblue-simple-client
TypeScript icon, indicating that this package has built-in type declarations

3.4.3 • Public • Published

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: 'dotnotreply@mydomain.com.br',
  };

  const destination: EmailUser = {
    name: 'John',
    email: 'john@doe.com',
  };

  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();

Readme

Keywords

none

Package Sidebar

Install

npm i @auronet/sendinblue-simple-client

Weekly Downloads

0

Version

3.4.3

License

MIT

Unpacked Size

7.79 kB

Total Files

8

Last publish

Collaborators

  • muecke36