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

lockit-sendmail

v1.1.2

Published

utilities for all the email communication from lockit

Downloads

38

Readme

Lockit sendmail

Build Status NPM version

Email utilities for Lockit.

Installation

npm install lockit-sendmail

var Email = require('lockit-sendmail');
var config = require('./config.js');

var email = new Email(config);

email.signup('john', '[email protected]', 'secret-token', function(err, res) {
  // res is the same res you would get from nodemailer
  // for more infos see https://github.com/andris9/Nodemailer#return-callback
})

Configuration

Add credentials to your config.js. This module uses nodemailer for sending emails. You can therefore use the same email types and email settings.

exports.emailType = 'SMTP';
exports.emailSettings = {
  service: 'Gmail',
  auth: {
    user: '[email protected]',
    pass: 'cowboy'
  }
};

Methods

Verify email address

A new user has signed up and his email address needs to be verified. An email with a link containing a unique token is sent to his email address. When the user clicks on this link we know that the given email address exists und belongs to the right user.

email.signup('john', '[email protected]', 'abc-123-def', function(err, res) {
  if (err) console.log(err);
  // ...
})

You can configure the email's content through your config.js. Just modify the emailSignup object. Here is a sample setup.

exports.emailSignup = {
  subject: 'Welcome to <%- appname %>',
  text: [
    '<h2>Hello <%- username %></h2>',
    'Welcome to <%- appname %>!',
    '<p><%- link %> to complete your registration.</p>'
  ].join(''),
  linkText: 'Click here'
};
  • subject - the email's subject
  • text - the email's body
  • linkText - the text of the link, which points back to our app

Duplicate email tries to sign up

A user tries to sign up with an email address that already exists. We send a hint to the right owner to indicate this happening. Never expose to a user whether an email address exists or not.

email.taken('john', '[email protected]', function(err, res) {
  if (err) console.log(err);
  // ...
})

You can configure the email's content through your config.js. Just modify the emailSignupTaken object. Here is a sample setup.

exports.emailSignupTaken = {
  subject: 'Email already registered',
  text: [
    '<h2>Hello <%- username %></h2>',
    'you or someone else tried to sign up for <%- appname %>.',
    '<p>Your email is already registered and you cannot sign up twice.',
    ' If you haven\'t tried to sign up, you can safely ignore this email. Everything is fine!</p>',
    '<p>The <%- appname %> Team</p>'
  ].join('')
};
  • subject - the email's subject
  • text - the email's body

Send email address verification link again

A user signed up but lost or didn't receive the email containing the link for his email address verification. Therefore he should be able to send the link again, with a different verification token.

email.resend('john', '[email protected]', 'abc-123-def', function(err, res) {
  if (err) console.log(err);
  // ...
})

You can configure the email's content through your config.js. Just modify the emailResendVerification object. Here is a sample setup.

exports.emailResendVerification = {
  subject: 'Complete your registration',
  text: [
    '<h2>Hello <%- username %></h2>',
    'here is the link again. <%- link %> to complete your registration.',
    '<p>The <%- appname %> Team</p>'
  ].join(''),
  linkText: 'Click here'
};
  • subject - the email's subject
  • text - the email's body
  • linkText - the text of the link, which points back to our app

Forgot password email

A user has forgotten his password and would like to create a new one. He enters his email address and an email with a link containing a secret token is sent to his email address.

email.forgot('john', '[email protected]', 'abc-123-def', function(err, res) {
  if (err) console.log(err);
  // ...
})

You can configure the email's content through your config.js. Just modify the emailForgotPassword object. Here is a sample setup.

exports.emailForgotPassword = {
  subject: 'Reset your password',
  text: [
    '<h2>Hey <%- username %></h2>',
    '<%- link %> to reset your password.',
    '<p>The <%- appname %> Team</p>'
  ].join(''),
  linkText: 'Click here'
};
  • subject - the email's subject
  • text - the email's body
  • linkText - the text of the link, which points back to our app

Test

$ npm test

License

MIT