Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed dotenv, updated README, and general cleanup. Closes #3 #4

Merged
merged 1 commit into from
May 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
language: node_js
node_js:
- '4.1'
- '4.0'
- '0.12'
- '0.10'
83 changes: 47 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,57 @@ SparkPost transport for Nodemailer
[![Build Status](https://travis-ci.org/SparkPost/nodemailer-sparkpost-transport.svg?branch=master)](https://travis-ci.org/Sparkpost/nodemailer-sparkpost-transport)
[![NPM version](https://badge.fury.io/js/nodemailer-sparkpost-transport.png)](http://badge.fury.io/js/nodemailer-sparkpost-transport) [![Slack Status](http://slack.sparkpost.com/badge.svg)](http://slack.sparkpost.com)

## Installation
## Usage

Install with npm

```
npm install nodemailer-sparkpost-transport
```

Require to your script

```javascript
var nodemailer = require('nodemailer');
var sparkPostTransport = require('nodemailer-sparkpost-transport');
```

Create a Nodemailer transport object

```javascript
var transporter = nodemailer.createTransport(sparkPostTransport(options))
```

Where

- **options** defines connection and message data
- `sparkPostApiKey` - SparkPost [API Key](https://app.sparkpost.com/account/credentials). If not provided, it will use the `SPARKPOST_API_KEY` env var.
- `campaign_id` - Name of the campaign
- `content` - Content that will be used to construct a message
- `metadata` - Transmission level metadata containing key/value pairs
- `options` - JSON object in which transmission options are defined
- `substitution_data` - Key/value pairs that are provided to the substitution engine

For more information, see the [SparkPost API Documentation for Transmissions](https://developers.sparkpost.com/api/#/reference/transmissions)



Send a message

```javascript
transport.sendMail(options, function(err, info) {});
```

Where

- **options** defines connection and message data
- `recipients` - Inline recipient objects or object containing stored recipient list ID. See [SparkPost API Documentation for Recipient Lists](https://developers.sparkpost.com/api/#/reference/recipient-lists) for more information.
- `campaign_id` - Override for option above
- `content` - Override for option above
- `metadata` - Override for option above
- `options` - Override for option above
- `substitution_data` - Override for option above

## Example

```javascript
Expand All @@ -19,8 +64,8 @@ npm install nodemailer-sparkpost-transport
var nodemailer = require('nodemailer');
var sparkPostTransport = require('nodemailer-sparkpost-transport');

// Will use dotenv to load .env variables, passing in options to send with SparkPost
var transporter = nodemailer.createTransport(sparkPostTransport({
"sparkPostApiKey": "<YOUR_API_KEY>",
"options": {
"open_tracking": true,
"click_tracking": true,
Expand Down Expand Up @@ -60,37 +105,3 @@ transporter.sendMail({
}
});
```

## Documentation

### `sparkPostTransport`

```javascript
sparkPostTransport(options);
```

#### Available options

+ `campaign_id`
+ `content`
+ `metadata`
+ `options`
+ `sparkPostApiKey`
+ `substitution_data`
+ `tags`

### `sendMail`

```javascript
transport.sendMail(options, function(err, info) {});
```

#### Available options

+ `campaign_id`
+ `content`
+ `metadata`
+ `options`
+ `recipients`
+ `substitution_data`
+ `tags`
3 changes: 0 additions & 3 deletions lib/sparkPostTransport.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict';

// Load environment configurations
require('dotenv').load();

// Dependencies
var pkg = require('../package');
var SparkPost = require('sparkpost');
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
},
"homepage": "https://github.com/SparkPost/nodemailer-sparkpost-transport",
"dependencies": {
"dotenv": "^1.2.0",
"email-addresses": "^2.0.1",
"sparkpost": "^1.1.0"
"sparkpost": "^1.3.5"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we mean to force people to keep current with node-sparkpost? Honestly not sure of our policy.

},
"devDependencies": {
"chai": "^2.2.0",
"mocha": "^2.2.1",
"sinon": "^1.14.1",
"chai": "^3.5.0",
"mocha": "^2.4.5",
"sinon": "^1.17.4",
"with-package": "^0.2.0"
}
}