项目
在 GitHub 查看
mfbx9da4/deep-email-validator
关于
检查正则表达式、拼写错误、一次性邮箱地址,以及 DNS 和 SMTP
系统与基础设施实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文deep-email-validator
Validates email addresses based on regex, common typos, disposable email blacklists, DNS records and SMTP server response.
- Validates email format (contains
@,.in domain, no spaces or control characters). - Validates common typos e.g.
[email protected]using mailcheck. - Validates email was not generated by a disposable email service using disposable-email-domains.
- Validates MX records are present on DNS.
- Validates SMTP server is running.
- Validates mailbox exists on SMTP server.
- Sanitizes inputs to prevent SMTP command injection.
- Native TypeScript support.
Getting Started
Requires Node.js >= 20. Server-side only (not browser compatible).
Installation
npm install deep-email-validator
Usage
import { validate } from 'deep-email-validator'
const res = await validate('[email protected]')
// {
// "valid": false,
// "reason": "smtp",
// "validators": {
// "regex": {
// "valid": true
// },
// "typo": {
// "valid": true
// },
// "disposable": {
// "valid": true
// },
// "mx": {
// "valid": true
// },
// "smtp": {
// "valid": false,
// "reason": "Mailbox not found.",
// }
// }
// }
You can also pass an options object to control which validations run:
await validate({
email: '[email protected]',
sender: '[email protected]',
validateRegex: true,
validateMx: true,
validateTypo: true,
validateDisposable: true,
validateSMTP: true,
})
Default options can be found here.
Custom TLDs
If you want to validate domains with TLDs that are not supported by default, use the additionalTopLevelDomains option:
await validate({
email: '[email protected]',
additionalTopLevelDomains: ['ir'],
})
For a list of TLDs supported by default, see mailcheck defaults.
CommonJS usage
const { validate } = require('deep-email-validator')
const res = await validate('[email protected]')
探索相关项目
加载中…