Skip to content

envialosimple-dev/transaccional-nodejs

Repository files navigation

EnvíaloSimple Transaccional - Node.js SDK

Requirements

Installation

npm install @envialosimple/transaccional

Basic Usage

import { Transaccional, MailParams } from "@envialosimple/transaccional";

const estr = new Transaccional(your_api_key);
const params = new MailParams();

params
    .setFrom('[email protected]', 'MyCompany Notifications')
    .setTo('[email protected]', 'John Doe')
    .setReplyTo('[email protected]')
    .setSubject('This is a test for {{name}}')
    .setPreviewText('A glimpse of what comes next...')
    .setHtml('<h1>HTML emails are cool, {{name}}</h1>')
    .setText('Text emails are also cool, {{name}}')
    .setContext({name: 'John'});


await estr.mail.send(params);

Multiple Recipients Usage

import { Transaccional, MailParams } from "@envialosimple/transaccional";

const estr = new Transaccional(your_api_key);
const params = new MailParams();

params
    .setFrom('[email protected]', 'MyCompany Notifications')
    .setTo([
      {email: '[email protected]', name: 'John Doe'},
      {email: '[email protected]', name: 'Jane Doe'},
      {email: '[email protected]'},
    ])
    .setReplyTo('[email protected]')
    .setSubject('This is a test for {{name}}')
    .setPreviewText('A glimpse of what comes next...')
    .setHtml('<h1>HTML emails are cool, {{name}}</h1>')
    .setText('Text emails are also cool, {{name}}')
    .setContext({name: 'John'});


await estr.mail.send(params);