@vijiniboson/otp-mail-service
v1.0.1
Published
Reusable OTP and Reset Email Service using Nodemailer
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({
from: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
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({
from: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
to: email,
type: "reset",
subject: "Email Verification OTP",
html: `
<h3>Password Reset</h3>
<p>Click below to reset your password:</p>
<a href="{{resetLink}}">Reset Password</a>
`,
resetLink: reset_link
});
Required Fields
- from → Sender email address
- pass → App password of email
- to → Receiver email
- type → "otp" or "reset"
- subject → Email subject
- html → HTML content
