UNPKG

email-validator-ultimate

Version:

Advanced email validator ultimate library for Node.js. Includes format checks, MX records, SMTP inbox validation, disposable email detection, and quality scoring. email validation email validator

144 lines (102 loc) โ€ข 4.29 kB
# ๐Ÿ“ง email-validator-ultimate A powerful Node.js email validation library that goes beyond regex. Performs DNS/MX record checks, SMTP deliverability tests, disposable email detection, and more. --- ## โš ๏ธ Important If you want to check if an email inbox exists (SMTP/bounce check), make sure: - Your server **allows outbound port 25** (many hosts block it by default). - You provide a **valid `fromEmail` sender** (e.g., `noreply@yourdomain.com`). - **SMTP check is optional** and **disabled by default**. ## ๐Ÿ”ง Features - โœ… **Format validation** (RFC-compliant) - ๐Ÿ“ฎ **MX record lookup** - โœ‰๏ธ **SMTP inbox existence check** _(optional)_ - ๐Ÿšซ **Disposable email detection** - ๐Ÿ‘ค **Generic username detection** (e.g., `admin`, `info`) - ๐Ÿ’ผ **Provider and domain info** - ๐Ÿ”ข **Email quality scoring** - ๐Ÿ†“ **Free email provider detection** (e.g., Gmail, Yahoo) - ๐Ÿ’ก **Catch-all detection** _(optional)_ ## ๐Ÿ“ฆ Installation ```bash npm install email-validator-ultimate ``` ## ๐Ÿ“ฆ Installation Basic Example (ESM) ```bash import { validateEmail } from 'email-validator-ultimate'; const result = await validateEmail({ email: 'someone@example.com', fromEmail: 'noreply@yourdomain.com', smtpCheck: true, // Enable SMTP validation (optional) debug: true // Optional SMTP debug logs }); console.log(result); ``` Using with Express (CommonJS) ```bash const { validateEmail } = require('email-validator-ultimate'); app.post('/validate', async (req, res) => { const result = await validateEmail({ email: req.body.email, fromEmail: 'noreply@yourdomain.com', smtpCheck: true }); res.json(result); }); ``` ## โœ… Validation Result Example ```bash { "email": "someone@example.com", "username": "someone", "domain": "example.com", "formatValid": true, "hasMX": true, "isDisposable": false, "isGeneric": false, "isFree": false, "provider": "Example", "mxRecord": "mx1.example.com", "canReceiveEmail": { "smtpSuccess": true, "message": "SMTP verification passed", "catchAll": false }, "qualityScore": 92 } ``` ## ๐Ÿงช Options | Option | Type | Required | Description | | :-------- | :-----: | :------: | :--------------------------------------- | | email | string | โœ… | Email address to validate | | fromEmail | string | โœ… | Email sender used for SMTP (if enabled) | | smtpCheck | boolean | โŒ | Enable SMTP inbox check (default: false) | | debug | boolean | โŒ | Log SMTP conversation to console | ## ๐Ÿค Contributing Contributions are welcome! Whether it's reporting bugs, suggesting features, or submitting pull requests, your help is appreciated. Please follow these guidelines: - Fork the repository and create your branch (`git checkout -b feature/your-feature`) - Commit your changes (`git commit -m 'Add some feature'`) - Push to the branch (`git push origin feature/your-feature`) - Open a pull request describing your changes Make sure your code passes all tests and adheres to the existing style. --- ## ๐Ÿ“„ License This project is licensed under the MIT License โ€” see the [LICENSE] file for details. ยฉ 2025 --- ## โœ๏ธ Author **Mehedi Hasan** ๐Ÿ“ง [aminulislamdev23@gmail.com](mailto:aminulislamdev23@gmail.com) ๐ŸŒ [GitHub](https://github.com/ai-mehedi) ## ๐Ÿ”‘ Keywords [Email validation](https://www.google.com/search?q=email+validation) ยท [SMTP check](https://www.google.com/search?q=SMTP+check) ยท [Disposable email detection](https://www.google.com/search?q=disposable+email+detection) ยท [MX record lookup](https://www.google.com/search?q=MX+record+lookup) ยท [Catch-all detection](https://www.google.com/search?q=catch-all+detection) ยท [Email format validation](https://www.google.com/search?q=email+format+validation) ยท [Node.js email validator](https://www.google.com/search?q=node.js+email+validator) ยท [Email quality scoring](https://www.google.com/search?q=email+quality+scoring) ยท [Generic username detection](https://www.google.com/search?q=generic+username+detection)