0.1.3 • Published 5 years ago

api-mailer v0.1.3

Weekly downloads
2
License
UNLICENSED
Repository
github
Last release
5 years ago

NPM version Downloads

Description

Mailer normalizes different service providers APIs (AWS SES, SendGrid, etc) into a single, consistent API interface. This provides modularity and portability. For example, if you change service providers (from SES to SendGrid), the API calls would remain the same. The only thing that would change would be the config file.

Install

$ npm install api-mailer

Setup

AWS: Setup your config file with your AWS SES credentials. See example.

SendGrid: Setup your config file with your SendGrid API Key. See example.

Basic usage

var sgConfig = require('./config/sendgrid-example.json')
var awsConfig = require('./config/aws-example.json')

var EmailMessage = require('dc-email-message');
var Mailer = require('api-mailer');
var Person = require('dc-person');
//It will detect the service provider on config file and use it
var mailer = new Mailer(sgConfig);

const recipient = new Person();
recipient.givenName = "RecipientFirst";
recipient.familyName = "RecipientLast";
recipient.email = "test@recipient.com";

const sender = new Person();
sender.givenName ="SenderFirst";
sender.familyName = "SenderLastName";
sender.email = "hello@sender.com";

let email = new EmailMessage();
email.recipient = recipient;
email.sender = sender;
email.subject = "Subject line";
email.text = "This is the text content"

mailer.sendEmail(email)
    .then(response => {/* success */})
    .catch(error => {/* error */})

Operations

OperationParams
sendEmail{email}

Tests

$ npm test
0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0-beta

7 years ago