# api-mailer

> Mail notification system

Latest version **0.1.3** (published 2019-03-26) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install api-mailer
pnpm add api-mailer
yarn add api-mailer
bun add api-mailer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2019-03-26 |
| First published | 2017-10-13 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | JoseBarrios |
| Maintainers | eaortiz2016, josebarrios |

## Links

- npm: https://www.npmjs.com/package/api-mailer
- Repository: https://github.com/JoseBarrios/api-mailer
- Homepage: https://github.com/JoseBarrios/api-mailer#readme
- Issues: https://github.com/JoseBarrios/api-mailer/issues
- npm.io page: https://npm.io/package/api-mailer

## Dependencies (5)

- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.428.0
- [dc-person](https://npm.io/package/dc-person.md) ^0.1.23
- [striptags](https://npm.io/package/striptags.md) ^3.1.1
- [@sendgrid/mail](https://npm.io/package/@sendgrid/mail.md) ^6.1.4
- [dc-email-message](https://npm.io/package/dc-email-message.md) ^0.2.1

## Recent versions

- 0.1.3 (latest) — 2019-03-26
- 0.1.2 — 2019-03-26
- 0.1.1 — 2019-03-26
- 0.1.0 — 2017-12-12
- 1.1.0 — 2017-11-23
- 1.0.0-beta — 2017-10-13

## README

[![NPM version][npm-image]][npm-url]
[![Downloads][download-badge]][npm-url]

### 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
```sh
$ npm install api-mailer
```


### Setup

*AWS*: Setup your config file with your AWS SES credentials. [See example](https://github.com/JoseBarrios/api-mailer/blob/master/config/aws-example.json).

*SendGrid*: Setup your config file with your SendGrid API Key. [See example](https://github.com/JoseBarrios/api-mailer/blob/master/config/sendgrid-example.json).
### Basic usage
```js
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
Operation  |    Params
-----------|----------------
sendEmail    | {email}

### Tests
```sh
$ npm test
```


[npm-url]: https://www.npmjs.com/package/api-mailer
[npm-image]: https://img.shields.io/npm/v/api-mailer.svg?style=flat-square
[download-badge]: http://img.shields.io/npm/dm/api-mailer.svg?style=flat-square

---
_Source: https://npm.io/package/api-mailer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
