Giter Club home page Giter Club logo

coresender-sdk-nodejs's Introduction

Coresender Node.js SDK

This is the officially supported Node.js library for Coresender. It allows you to quickly and easily integrate with our API and improve your email deliverability.

Prerequisites

What things you need to install the software and how to install them

  • Node.js v6 or higher
  • The Coresender service. You can start with a free 100 emails/month developer plan and move to one of our pricing plans when you're done.

Installation

Install the library with

npm install --save coresender

Usage

Simple email
const {Coresender, BodyType} = require('coresender');

const client = new Coresender('account_id', 'account_secret');

const params = {
    fromEmail: '[email protected]',
    toEmail: '[email protected]',
    subject: 'Hello Bob',
    body: '<div>Nice to meet you.</div>',
    bodyType: BodyType.HTML,
};

const result = await client.simpleEmail(params);
Result
{
  messageId: 'd2a82708-2067-4b3b-8866-b33355036fde',
  customId: '',
  status: 'accepted',
  errors: []
}
Email request
const {Coresender} = require('coresender');

const client = new Coresender('account_id', 'account_secret');

const request = client.sendEmailRequest();

// required fields only
request.addToBatch({
    fromEmail: '[email protected]',
    toEmail: '[email protected]',
    subject: 'Hello Bob',
    bodyText: 'Nice to meet you.',
});

// available fields
request.addToBatch({
    fromEmail: '[email protected]',
    fromName: 'Alice',
    toEmail: '[email protected]',
    toName: 'Bob',
    subject: 'Hello Bob',
    bodyText: 'Nice to meet you.',
    trackOpens: true,
    trackClicks: true,
    listUnsubscribe: 'https://unsub.me/',
    listId: '000471416624-654a-3d21-b98e-7654e321',
    customId: '123e4567-e89b-12d3-a456-426614174000',
    customIdUnique: true,
    bodyHTML: '<div>Nice to meet you.</div>',
    replyTo: [{email: '[email protected]', name: 'Support'}],
});

const result = await request.execute();
Result object
result.allAccepted() // returns TRUE if all messages was accepted
result.getItems() // returns array of status objects for all messages

// Example result from getItems() method
[
  {
    messageId: 'ff191365-316e-41e0-a185-5c7433d92b8a',
    customId: '',
    status: 'accepted',
    errors: []
  },
  {
    messageId: '',
    customId: '',
    status: 'rejected',
    code: 'EMAIL_SUPPRESSED',
    errors: [
      {
        code: 'EMAIL_SUPPRESSED',
        description: "The recipient's email address [email protected] is on a suppression list"
      }
    ]
  }
]

Debugging

To enable debug logging for coresender module set NODE_DEBUG environment variable to coresender.

$ NODE_DEBUG=coresender node app.js

Contribute

The Coresender Node.js SDK is an open-source project released under MIT license. We welcome any contributions!

You can help by:

  • Writing new code
  • Creating issues if you find problems
  • Helping others with their issues
  • Reviewing PRs

coresender-sdk-nodejs's People

Contributors

kornel-kedzierski avatar slawekp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.