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

knoxxnxt-mail

v0.2.0

Published

Email sending helper built on top of nodemailer and email-templates

Downloads

6

Readme

Mail

Email sending helper built on top of nodemailer and email-templates

It doesn't do anything fancy, it simply makes it quicker to get started. In the future, this will become the place with all the best practices so that doesn't need to be replicated across multiple projects.

Installation

Install the module as a git npm module. For example, to install v0.2.0 use the following command:

$ npm install --save git+ssh://[email protected]:jksdua__common/mail.git#v0.2.0

Usage

Step 1 - Create the mail client

var templatesDir = __dirname + '/templates';

var mail = require('js_mail')({
	templates: { dir: templatesDir },
	transport: require('nodemailer-smtp-transport')()
});

Step 2 - Send emails and have fun!

yield mail.send({
	template: {
		name: 'template-a',
		locals: { some: 'param', another: 'param' }
	},
	mail: {
		from: '[email protected]',
		to: '[email protected]'
	}
});

API Documentation

Mail()

Mail client

@class Mail
@constructor
@param {Object} options Mail client options
	@param {Object} options.templates Templates options
		@param {String} options.templates.dir Directory with templates
	@param {Object} options.transport Transport instance

@example
	var path = require('path');

	var templatesDir = path.join(__dirname, '/templates');

	var mail = require('js_mail')({
		templates: { dir: templatesDir },
		transport: require('nodemailer-stub-transport')()
	});

options

Options used to initialise the instance

@property options

transport

Mail transport used to send emails

@property transport

template

Loaded email templates

@property template

schema

Schema for args passed to various methods

@property schema
@type Object

defaults

Default options for various methods

@property defaults
@type Object

init()

Initialises email - loads templates

@method init
@async

@example
	yield mail.init();

send()

Sends an email

@method send
@param {Object} options Sending mail options
	@param {Object} options.template Template options
		@param {String} options.template.name Name of the template
		@param {Object} options.template.locals Locals passed to the renderer
	@param {Object} options.mail Mail options. See `nodemailer` for details.
@async

@example
	yield mail.send({
		template: {
			name: 'pasta-dinner',
			locals: { firstName: 'John', lastName: 'Smith' }
		},
		mail: {
			from: '[email protected]',
			to: '[email protected]',
			subject: 'Hello world!'
		}
	});

Generated using the following command:

> ./node_modules/.bin/markdox index.js

Test

Tests can be run using mocha

$ git clone [email protected]:jksdua__common/mail.git

$ npm install

$ npm test

Changelog

v0.2.0 (28 January 2015)

  • Bumped dependencies

v0.1.0 (9 September 2014)

  • Updated nodemailer version

v0.0.1 (7 September 2014)

  • Initial commit