otp-mail-service
v1.0.8
Published
Both Nodemailer integration and OTP generation are handled within a single package.
Maintainers
Readme
OTP Mail Service
Reusable OTP and Reset Email Service using Nodemailer.
Installation
npm install otp-mail-serviceUsage
import { sendEmail } from "otp-mail-service";
// For OTP
await sendEmail({
to: "[email protected]",
type: "otp",
subject: "Email Verification OTP",
html: `
<h3>Your OTP is {{otp}}</h3>
`
});
// For Reset Link
const reset_link = `http://localhost:****/reset-password?token=${token}`;
await sendEmail({
to: "[email protected]",
type: "reset",
subject: "Password Reset",
html: `
<h3>Password Reset</h3>
<p>Click below to reset your password:</p>
<a href="{{resetLink}}">Reset Password</a>
`,
resetLink: reset_link
});Required Fields
- to → Receiver email
- type → "otp" or "reset"
- subject → Email subject
- html → HTML content
- Note: Sender email and password are automatically read from your .env file (EMAIL_USER & EMAIL_PASS). No need to pass them manually.
