npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paubox-node

v1.2.5

Published

A Node.js module for the Paubox Transactional Email API.

Downloads

4,616

Readme

Paubox NodeJS

This is the official NodeJS wrapper for the Paubox Email API.

The Paubox Email API allows your application to send secure, compliant email via Paubox and track deliveries and opens. The API wrapper allows you to construct and send messages.

Table of Contents

Further documentation can be found at docs.paubox.com.

Installation

Using npm:

$ npm install --save paubox-node

Getting Paubox API Credentials

You will need to have a Paubox account. You can sign up here.

Once you have an account, follow the instructions on the Rest API dashboard to verify domain ownership and generate API credentials.

Configuring API Credentials

Include your API credentials in your environment file.

Your "API Username" comes from your unique API endpoint.

Base URL: https://api.paubox.net/v1/<USERNAME>

$ echo "API_KEY='YOUR_API_KEY'" > .env
$ echo "API_USERNAME='YOUR_ENDPOINT_NAME'" >> .env
$ echo ".env" >> .gitignore

Or pass them as parameters when creating emailService

const pbMail = require('paubox-node');
const pauboxConfig = {
  apiUsername: 'your-api-username',
  apiKey: 'your-api-key',
};
const service = pbMail.emailService(pauboxConfig);

Usage

To send email, prepare a Message object and call the sendMessage method of emailService.

Sending messages

"use strict";
require('dotenv').config();
const pbMail = require('paubox-node');
const service = pbMail.emailService();

var options = {
  from: '[email protected]',
  to: ['[email protected]'],
  subject: 'Testing!',
  text_content: 'Hello World!',
  html_content: '<html><head></head><body><h1>Hello World!</h1></body></html>',
}

var message = pbMail.message(options)

service.sendMessage(message)
  .then(response => {
    console.log("Send Message method Response: " + JSON.stringify(response));
  }).catch(error => {
    console.log("Error in Send Message method: " + JSON.stringify(error));
  });

Allowing non-TLS message delivery

If you want to send non-PHI mail that does not need to be HIPAA compliant, you can allow the message delivery to take place even if a TLS connection is unavailable.

This means the message will not be converted into a secure portal message when a nonTLS connection is encountered. To do this, include allowNonTLS: true in the options, as shown below:

"use strict";
require('dotenv').config();
const pbMail = require('paubox-node');
const service = pbMail.emailService();

var options = {
  allowNonTLS: true,
  from: '[email protected]',
  to: ['[email protected]'],
  subject: 'Testing!',
  text_content: 'Hello World!',
  html_content: '<html><head></head><body><h1>Hello World!</h1></body></html>',
}

var message = pbMail.message(options)

Forcing Secure Notifications

Paubox Secure Notifications allow an extra layer of security, especially when coupled with an organization's requirement for message recipients to use 2-factor authentication to read messages (this setting is available to org administrators in the Paubox Admin Panel).

Instead of receiving an email with the message contents, the recipient will receive a notification email that they have a new message in Paubox.

"use strict";
require('dotenv').config();
const pbMail = require('paubox-node');
const service = pbMail.emailService();

var options = {  
  forceSecureNotification: 'true',
  from: '[email protected]',
  to: ['[email protected]'],
  subject: 'Testing!',
  text_content: 'Hello World!',
  html_content: '<html><head></head><body><h1>Hello World!</h1></body></html>',
}

var message = pbMail.message(options)

Adding the List-Unsubscribe Header

The List-Unsubscribe header provides the recipient with the option to easily opt-out of receiving any future communications. A more detailed explaination and usage guide for this header can be found at our docs here.

This header can be used by adding the list_unsubscribe: '<Email Unsubscribe Address>, <Web Unsubscribe URL' and list_unsubscribe_post: 'List-Unsubscribe=One-Click' key-value pairs to the options object as follows:

"use strict";
require('dotenv').config();
const pbMail = require('paubox-node');
const service = pbMail.emailService();

var options = {
  from: '[email protected]',
  to: ['[email protected]'],
  subject: 'Testing!',
  text_content: 'Hello World!',
  html_content: '<html><head></head><body><h1>Hello World!</h1></body></html>',
  list_unsubscribe: '<mailto: [email protected]?subject=unsubscribe>, <http://www.example.com/unsubscribe.html>',
  list_unsubscribe_post: 'List-Unsubscribe=One-Click'
}

var message = pbMail.message(options)


### Adding Attachments and Additional Headers


```javascript
"use strict";
require('dotenv').config();
const pbMail = require('paubox-node');
const service = pbMail.emailService();

var attachmentContent = Buffer.from('Hello! This is the attachment content!').toString('base64')

var options = {
  from: '[email protected]',
  reply_to: '[email protected]',
  to: ['[email protected]'],
  bcc: ['[email protected]'],
  cc: ['[email protected]'],
  subject: 'Testing!',
  text_content: 'Hello World!',
  html_content: '<html><head></head><body><h1>Hello World!</h1></body></html>',
  attachments: [{
    fileName: "HelloWorld.txt",
    contentType: "text/plain",
    content: attachmentContent
  }]
}

var message = pbMail.message(options)

Checking Email Dispositions

The SOURCE_TRACKING_ID of a message is returned in the response of the sendMessage method. To check the status for any email, use its source tracking id and call the getEmailDisposition method of emailService:

"use strict";
require('dotenv').config();
const pbMail = require('paubox-node');
const service = pbMail.emailService();

service.getEmailDisposition("SOURCE_TRACKING_ID")
  .then(function (response) {
      console.log("Get Email Disposition method Response: " + JSON.stringify(response));
  });

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/paubox/paubox-node.

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright

Copyright © 2021, Paubox, Inc.