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

nodemailer-otp

v1.0.8

Published

A simple Node.js helper for generating OTPs and sending email notifications using Nodemailer.

Downloads

64

Readme

nodemailer-otp

Nodemailer-otp is a simple Node.js package that allows developers to easily generate OTPs (One Time Passwords) and send email notifications using Nodemailer. This package provides easy integration into your Node.js projects and supports customizable OTP lengths.

Features

  • Generate OTPs for use in your application
  • Send OTPs and custom messages via email using Nodemailer
  • Simple and customizable integration with your Node.js project
  • Easy setup and usage

Installation

To get started with nodemon-helper, follow these steps:

npm install nodemailer-otp 

Create a .env file in your project's root directory:

[email protected]
EMAIL_PASS=your-email-access-key

Setup Instructions

Email Provider Configuration

  1. Gmail Setup:

    • Enable "Less Secure Apps" in your Gmail account settings, or
    • Generate an App-Specific Password if using 2-factor authentication
    • Use the app password in your .env file
  2. Dependencies:

    npm install nodemailer

Usage

Basic Setup

const NodemailerHelper = require('nodemailer-otp');
require('dotenv').config();

// Initialize the helper
const helper = new NodemailerHelper(process.env.EMAIL_USER, process.env.EMAIL_PASS);

For (ESM) Syntax

import NodemailerHelper from 'nodemailer-otp';
import dotenv from 'dotenv';

// Load environment variables from .env file
dotenv.config();

// Initialize the helper
const helper = new NodemailerHelper(process.env.EMAIL_USER, process.env.EMAIL_PASS);

Generate OTP

// Generate a 6-digit OTP
const otp = helper.generateOtp(6);
console.log(`Generated OTP: ${otp}`);

Send OTP via Email

helper.sendEmail('[email protected]','subject','your message here!', otp)
  .then((response ) => {
    console.log(response );
  })
  .catch((err) => {
    console.error(err);
  });

API Reference

NodemailerHelper(email, emailAccessKey)

Constructor for initializing the helper with your email credentials.

  • email: Your email address
  • emailAccessKey: Email provider access key or app-specific password

generateOtp(length)

Generates an OTP.

  • length: Number (4) //you can generate any length of otp.
  • Returns: String containing the generated OTP

sendOtp(recipientEmail, otp)

Sends OTP via email.

  • recipientEmail: Recipient's email address
  • otp: OTP to send
  • Returns: Promise

Troubleshooting

Gmail Issues

  • Verify "Less Secure Apps" is enabled or use App-Specific Password
  • Confirm email credentials in .env file are correct

OTP Generation Issues

  • Check console logs for generated OTP is working

Email Sending Issues

  • Review error logs
  • Verify email configuration in .env
  • Check email service status and account restrictions

Contributing

We welcome contributions! Feel free to:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.