# nodemailer-sparkpost-transport

> SparkPost transport for Nodemailer

Latest version **2.2.0** (published 2018-11-09) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install nodemailer-sparkpost-transport
pnpm add nodemailer-sparkpost-transport
yarn add nodemailer-sparkpost-transport
bun add nodemailer-sparkpost-transport
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2018-11-09 |
| First published | 2015-08-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 36.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | SparkPost |
| Maintainers | avigoldman, sparkpost |
| Keywords | nodemailer, sparkpost |

## Links

- npm: https://www.npmjs.com/package/nodemailer-sparkpost-transport
- Repository: https://github.com/SparkPost/nodemailer-sparkpost-transport
- Issues: https://github.com/SparkPost/nodemailer-sparkpost-transport/issues
- npm.io page: https://npm.io/package/nodemailer-sparkpost-transport

## Dependencies (1)

- [sparkpost](https://npm.io/package/sparkpost.md) ^2.1.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2018-11-09
- 2.1.0 — 2018-07-16
- 2.0.0 — 2017-01-06
- 1.1.0 — 2016-11-10
- 1.0.0 — 2016-07-26
- 0.1.2 — 2016-05-17
- 0.1.0 — 2015-08-28

## README

<a href="https://www.sparkpost.com"><img src="https://www.sparkpost.com/sites/default/files/attachments/SparkPost_Logo_2-Color_Gray-Orange_RGB.svg" width="200px"/></a>

[Sign up](https://app.sparkpost.com/join?plan=free-0817?src=Social%20Media&sfdcid=70160000000pqBb&pc=GitHubSignUp&utm_source=github&utm_medium=social-media&utm_campaign=github&utm_content=sign-up) for a SparkPost account and visit our [Developer Hub](https://developers.sparkpost.com) for more resources.

# SparkPost transport for Nodemailer
## nodemailer-sparkpost-transport

[![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)

## Usage

### Install

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

### Create a Nodemailer transport object

```javascript
var nodemailer = require('nodemailer');
var sparkPostTransport = require('nodemailer-sparkpost-transport');
var transporter = nodemailer.createTransport(sparkPostTransport(options));
```

where:

  - **options** defines connection _default_ transmission properties
    - `sparkPostApiKey` - SparkPost [API Key](https://app.sparkpost.com/account/api-keys). If not provided, it will use the `SPARKPOST_API_KEY` env var.
    - `endpoint` - The endpoint to use for the SparkPost API requests. If you have a SparkPost EU account, set this to `https://api.eu.sparkpost.com` (optional)
    - `campaign_id` - Name of the campaign (optional)
    - `metadata` - Transmission level metadata containing key/value pairs (optional)
    - `options` - JSON object in which transmission options are defined (optional)
    - `substitution_data` - Key/value pairs that are provided to the substitution engine (optional)

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

## Send a message

```javascript
transport.sendMail({
  from: 'me@here.com',
  to: 'you@there.com',
  subject: 'Very important stuff',
  text: 'Plain text',
  html: 'Rich taggery'
}, function(err, info) {
  if (err) {
    console.log('Error: ' + err);
  } else {
    console.log('Success: ' + info);
  }
});
```

[Read more about Nodemailer's `sendMail()` method here](https://github.com/nodemailer/nodemailer#sending-mail).

### Additional Options

The SparkPost Nodemailer transport also supports a few SparkPost-specific `sendMail()` options in both the transport constructor and the 'sendMail()` method.

Note: `sendMail()` options override their constructor counterparts:

  - **options**
    - `campaign_id` - Overrides for constructor option
    - `metadata` - Override for constructor option
    - `options` - Override for constructor option
    - `substitution_data` - Override for constructor option

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