Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodemailer-sparkpost-transport

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodemailer-sparkpost-transport

SparkPost transport for Nodemailer

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by11.22%
Maintainers
1
Weekly downloads
 
Created
Source

nodemailer-sparkpost-transport

SparkPost transport for Nodemailer

Build Status NPM version Slack Status

Usage

Install with npm

npm install nodemailer-sparkpost-transport

Require to your script

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

Create a Nodemailer transport object

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

Where

  • options defines connection and message data
    • sparkPostApiKey - SparkPost API Key. 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

Send a message

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 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

'use strict';

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

var transporter = nodemailer.createTransport(sparkPostTransport({
  "sparkPostApiKey": "<YOUR_API_KEY>",
  "options": {
    "open_tracking": true,
    "click_tracking": true,
    "transactional": true
  },
  "campaign_id": "Nodemailer Default",
  "metadata": {
    "some_useful_metadata": "testing_sparkpost"
  },
  "substitution_data": {
    "sender": "YOUR NAME",
    "fullName": "YOUR NAME",
    "productName": "The coolest product ever",
    "sparkpostSupportEmail": "support@sparkpost.com",
    "sparkpostSupportPhone": "123-456-7890"
  },
  "content": {
    "template_id": "ADD YOUR TEMPLATE ID HERE"
  }
}));


transporter.sendMail({
  "recipients": [
    {
      "address": {
        "email": "CHANGE TO YOUR TARGET TEST EMAIL",
        "name": "CHANGE TO YOUR RECIPIENT NAME"
      }
    }
  ]
}, function(err, info) {
  if (err) {
    console.error(err);
  } else {
    console.log(info);
  }
});

Keywords

FAQs

Package last updated on 17 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc