block-temp-mail
v1.0.6
Published
A lightweight package to detect and block disposable or temporary email addresses, helping prevent spam and fake account registrations.
Maintainers
Readme
block-temp-mail
A lightweight Node.js package to detect disposable/temporary email addresses. Protect your app from fake signups by verifying whether an email belongs to a temporary mail service.
Installation
npm install block-temp-mailUsage
ESM
import { verifyEmail } from "block-temp-mail";
const result = await verifyEmail("[email protected]");
console.log(result);CommonJS
const { verifyEmail } = require("block-temp-mail");
async function check() {
const result = await verifyEmail("[email protected]");
console.log(result);
}
check();API
verifyEmail(email: string): Promise<VerifyEmail>
Checks whether the given email is a disposable/temporary email address.
Parameters:
| Parameter | Type | Description |
| --------- | -------- | ------------------------ |
| email | string | The email address to verify |
Returns: Promise<VerifyEmail>
type VerifyEmail = {
success: boolean;
message: string;
data: {
isTemporary: boolean;
isValid: boolean;
message: string;
};
};Response Examples
Temporary email detected:
{
"success": true,
"message": "Email verified successfully.",
"data": {
"isTemporary": true,
"isValid": true,
"message": "Temporary email."
}
}Valid, non-temporary email:
{
"success": true,
"message": "Email verified successfully.",
"data": {
"isTemporary": false,
"isValid": true,
"message": "Valid email."
}
}Invalid email format:
{
"success": false,
"message": "Invalid email format.",
"data": {
"isTemporary": false,
"isValid": false,
"message": "Invalid email."
}
}Use Cases
- Block disposable emails during user registration
- Validate email quality in lead generation forms
- Prevent abuse in free-tier signups
License
MIT - Tara Chand Kumawat
