# node-otp-sender

> This is a simple package that used to send email-otp using node-mailer

Latest version **1.0.21** (published 2024-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-otp-sender
pnpm add node-otp-sender
yarn add node-otp-sender
bun add node-otp-sender
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.21 |
| Published | 2024-10-05 |
| First published | 2023-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 (+22 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Muhd Hanish |
| Maintainers | muhdhanish |
| Keywords | node, mailer, OTP, sender, email, authentication, security, JavaScript, TypeScript |

## Links

- npm: https://www.npmjs.com/package/node-otp-sender
- Repository: https://github.com/MuhdHanish/node_otp_sender
- Homepage: https://github.com/MuhdHanish/node_otp_sender#readme
- Issues: https://github.com/MuhdHanish/node_otp_sender/issues
- npm.io page: https://npm.io/package/node-otp-sender

## Dependencies (2)

- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [nodemailer](https://npm.io/package/nodemailer.md) ^6.9.15

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.21 (latest) — 2024-10-05
- 1.0.20 — 2024-10-05
- 1.0.19 — 2024-10-05
- 1.0.18 — 2024-10-05
- 1.0.17 — 2024-10-05
- 1.0.16 — 2024-10-05
- 1.0.15 — 2024-10-05
- 1.0.14 — 2024-10-05
- 1.0.13 — 2024-10-05
- 1.0.12 — 2024-10-05
- 1.0.11 — 2024-10-05
- 1.0.10 — 2023-09-24
- 1.0.9 — 2023-09-23
- 1.0.8 — 2023-09-21
- 1.0.7 — 2023-09-21
- … 4 more at https://npm.io/package/node-otp-sender/versions

## README

# Node OTP Sender

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![npm Version](https://img.shields.io/npm/v/node-otp-sender.svg)](https://www.npmjs.com/package/node-otp-sender)

A simple and lightweight npm package for sending one-time passwords (OTPs) via email using Nodemailer with retry functionality.

## Features

- Generate and send one-time passwords (OTPs) via email
- Secure OTP generation using the `crypto` module
- Retry sending OTP emails in case of temporary network or email server issues
- Simple and easy to use
- Customizable OTP length and retry behavior

## Installation

Install the package using npm:

```bash
npm install node-otp-sender
```

## Usage

```typescript
import { nodeOtpSender } from 'node-otp-sender';

const config = {
  senderEmail: 'your-email@example.com',
  senderPassword: 'your-email-password',
  recipientEmail: 'recipient-email@example.com',
  subject: 'OTP Verification',
  length: 4, // Length of the OTP (default is 4)
  maxRetries: 3, // Number of retry attempts (default is 3)
  retryDelay: 1000 // Delay between retries in milliseconds (default is 1000ms)
};

const sendOtp = async () => {
  try {
    const response = await nodeOtpSender(config);
    console.log(response);
  } catch (error) {
    console.error('Error:', error);
  }
};

sendOtp();
```

## Customizing Retry Behavior

You can customize the retry behavior by adjusting the `maxRetries` and `retryDelay` parameters in the configuration object. `maxRetries` determines the maximum number of retry attempts, and `retryDelay` sets the delay between retry attempts.

## Customizing OTP Length

You can specify the length of the OTP by adjusting the `length` parameter in the configuration object. The default length is set to 4 digits, but you can change it to any desired length.

Make sure to replace:

- `your-email@example.com` with your actual sender email.
- `your-email-password` with the password of your sender email.
- `recipient-email@example.com` with the recipient's email address.
- `OTP Verification` with your desired subject.

## Feedback

If you have any feedback, please reach me at [muhammedhanish11@gmail.com](mailto:muhammedhanish11@gmail.com) or connect with me on [LinkedIn](https://www.linkedin.com/in/muhdhanish/).

---
_Source: https://npm.io/package/node-otp-sender · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
