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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jrh-works/mail

v1.0.0

Published

Send emails from Node.js (via SendGrid) with optional test runs.

Downloads

3

Readme

@jrh-works/mail

Send emails from Node.js (via SendGrid) with optional test runs.

Installation

npm install @jrh-works/mail

The Configuration Function

Usage

const configureSend = require('@jrh-works/mail')

Syntax

configureSend(options)

Arguments

| Name | Type | Description | | :-- | :-- | :-- | | options | Object: ConfigureOptions | Configuration for all mailers. |

Returns

| Type | Description | | :-- | :-- | | Function: Send | A send function for sending mail. |

Exceptions

Throws a standard Error if:


The ConfigureOptions Object

| Attribute | Type | Description | | :-- | :-- | :-- | | dry | Boolean (default: false) | If set to true, generated mailers will always perform dry runs. This overrides the individual mailer options. | | key | String | A SendGrid API key to use when sending mail. | | mail | Object (default: @sendgrid/mail) | A SendGrid mail implementation. | | sender | Object: Sender | A default sender to send messages from. |


The Sender Object

| Attribute | Type | Description | | :-- | :-- | :-- | | name | String | The name of the sender. | | email | String | The email of the sender. |


The Send Function

Syntax

send(type, messages, options)

Arguments

| Name | Type | Description | | :-- | :-- | :-- | | type | String | A name for the type of mail being sent, used for logging. | | message | Object:Message | Array [Object: Message] | One or more message objects representing the message(s) to be sent. | | options | Object: Options | Configuration for this mailer. |

Returns

| Type | Description | | :-- | :-- | | Object: Promise | A promise to send mail via the SendGrid mail implementation. |

Exceptions

Throws a standard Error if:

  • No type is present.
  • No message is present.
  • The message object does not contain all required properties.
  • The options object does not contain all required properties.

Effects

  • Mail will be sent via the SendGrid mail implementation.
  • Information will be logged using log function provided to the mailer.

During a live run:

  • The default sender will be BCC'd on all messages.

During a dry run:

  • All mail will be redirected to the default sender.
  • Debugging information including the original recipient(s) will be added to the template data.

The Message Object

| Attribute | Type | Description | | :-- | :-- | :-- | | attachment (optional) | Object: Attachment | An attachment to send with the email. | | data (optional) | Object (optional) | Template data to use in the dynamic template. | | template_id | String | A SendGrid dynamic template ID. | | to | Object: Person | Array [Object: Person] | One or more people to send this message to. | | bcc | Object: Person | Array [Object: Person] | One or more people to blind-copy on this message. |


The Attachment Object

| Attribute | Type | Description | | :-- | :-- | :-- | | filename | String | The filename for the attachment. | | content | String | A Base64 encoded string containing the file data. |


The Person Object

| Attribute | Type | Description | | :-- | :-- | :-- | | emails | Array | A list of one or more emails to use for this person. | | greeting | String | A greeting to be used when addressing this person (i.e. Dear [greeting],) | | name | String | The person's full name. |


The Options Object

| Attribute | Type | Description | | :-- | :-- | :-- | | dry | Boolean (default: false) | Whether or not to perform a dry run. This can be overridden in the ConfigureOptions. | | log | Function: Log | A log function which will be used to log mailing information. |


The Log Function

A function for logging information.

The function should include an .error() property for logging errors.

Example Syntax
function log(value) {
  console.log(value)
}

log.error = (error) => {
  console.error(error)
}