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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sender-js

v0.6.3

Published

Universal sender module

Downloads

58

Readme

sender-js

Simple Node.js module for sending messages by e-mail, Slack, Telegram or HTTP API.

Installation

npm install sender-js

Usage overview

This module provides e-mail sending functionality via Nodemailer or Mailgun modules, supports sending messages to Slack team collaboration tool as well as HTTP API is supported too.

The messages can be sent separately or by all four services simultaneously.

Common Nodemailer usage with single service instance:

var sender = require('sender-js');

var settings = {
  gmail: {
    "username": "[email protected]",
    "password": "yourPassword"
	}
};

sender.init(settings);

var messageOptions = {
	to: '[email protected]',
	from: '[email protected]',
  subject: 'fff',
  text: 'test nodemailer text'
};

sender.send(messageOptions, function(err, message) {
	console.log(err + ' ' + message);
});

Common Mailgun usage with single service instance:

var sender = require('sender-js');

var settings = {
  mailgun: {
    "apiKey": "key-somekey",
    "domain": "mg.yourdomain"
	}
};

sender.init(settings);

var messageOptions = {
	to: '[email protected]',
	from: '[email protected]',
  subject: 'fff',
  text: 'test mailgun test'
};

sender.send(messageOptions, function(err, message) {
	console.log(err + ' ' + message);
});

Common Slack usage with single service instance:

var sender = require('sender-js');

var settings = {
  slack: {
    "token": "sasd-asdasdasdasdasdasda"
	}
};

sender.init(settings);

var messageOptions = {
	to: 'common',
  text: 'test slack text'
};

sender.send(messageOptions, function(err, message) {
	console.log(err + ' ' + message);
});

Common HTTP usage with single service instance:

var sender = require('sender-js');

var settings = {
  http: {
    "url": "http://some.url",
		"method": "POST",
		"json": true,
		"headers": {
			"Content-type": "your content type",
			"Custom-header": "some header"
		},
		"queryString": {
			"id": 113
		}
	}
};

sender.init(settings);

var messageOptions = {
  text: 'test slack text'
};

sender.send(messageOptions, function(err, message) {
	console.log(err + ' ' + message);
});

Common Telegram usage with single service instance:

var sender = require('sender-js');

var settings = {
  telegram: {
    "token": "43432424234:asdasdasdasdasdasda",
    "chatId": "-25434543" // Can be ommited
	}
};

sender.init(settings);

var messageOptions = {
  text: 'test slack text'
};

sender.send(messageOptions, function(err, message) {
	console.log(err + ' ' + message);
});

To send messages to Telegram sender-js needs respective chat ID. Chat ID can be received automatically by sending /start command to the library. To do that you need follow the next few steps:

  1. Add BotFather (@BotFather) to your chat
  2. Create new bot with /newbot command
  3. Add generated bot token to Telegram sender-js settings
  4. Add generated bot to your chat
  5. Start your application with sender-js lib
  6. Send /start command from Telegram to newly created bot

Also there is an option to add chat ID manually, if you already have it. There is one way to get it for the group chat:

  1. Open Telegram Web in your browser
  2. Do the necessary authorization
  3. Create new chat group and add your bot to it
  4. In browser address bar there is chat ID which looks like g144782871
  5. Add it to sender-js settings as chatId field replacing "g" with "-": -144782871

Now sender-js can send messages to the group without /start command. Also you can transmit group chat ID to sender-js with the first technique described above.

To send multiple messages you should specify options to all services you going to use:

var sender = require('sender-js');

var settings = {
	gmail: {
    "username": "[email protected]",
    "password": "yourPassword"
	},
	mailgun: {
    "apiKey": "key-somekey",
    "domain": "mg.yourdomain"
	},
  slack: {
    "token": "sasd-asdasdasdasdasdasda"
	},
	http: {
    "url": "http://jsonplaceholder.typicode.com/posts",
    "method": "POST",
    "json": true,
		"headers": {
			"Content-type": "your content type",
			"Custom-header": "some header"
		},
		"queryString": {
			"id": 11
		}
  }
};

// If we don't use the second argument, multiple service objects will be created
sender.init(settings);

var messageOptions = {
	to: '[email protected]',
	from: '[email protected]',
  subject: 'fff',
  text: 'test mailgun test',
	slack: {	// Slack destination name should be specified separately
	 to: 'common'
	},
	http: {	// HTTP request URL is specified separately, if needed
		url: 'http://some.url'
	}
};

sender.send(messageOptions, function(err, message) {
	console.log(err + ' ' + message);
});

Tests

To run the test suite you must provide e-mail and Mailgun credetials. E-mail credentials is passed to Nodemailer module and Mailgun requires api key and domain setup to run.

All test settings are stored in ./test/settings.json file. Before running test update it with your credentials.

Then install the dev dependencies and execute the test suite:

$ npm install
$ npm test

The tests will call all module functions and will check the sending functionality.

License

Copyright 2015 Invatechs

Licensed under the MIT License.