
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
disposable-email-validator
Advanced tools
Block disposable emails with environment-specific rules and plus addressing validation
Filter temporary/disposable email domains and normalize email addresses, with environment-specific rules.
user+tag@gmail.com
)development
, staging
, production
, my-app-env
, etc.)npm install disposable-email-validator
import { DisposableEmailValidator } from 'disposable-email-validator';
const config = {
production: {
rules: {
allow_disposable_emails: false,
allow_plus_addressing: false,
}
}
};
const validator = new DisposableEmailValidator('production', config);
const result = validator.validateEmail('user@10minutemail.com');
console.log(result);
// { success: false, error: 'Disposable email addresses are not allowed' }
The library uses environment-based configuration to support different validation rules across any environment you define. While development
, staging
, production
, and test
are common examples, you can use any environment names that match your setup.
const config = {
development: {
rules: {
allow_disposable_emails: true,
allow_plus_addressing: true
}
},
production: {
rules: {
allow_disposable_emails: false,
allow_plus_addressing: false
},
disposableDomains: ['10minutemail.com', 'tempmail.org'],
trustedDomains: ['company.org', 'company.com'],
mergeDisposableDomains: true
},
'my-custom-env': {
rules: {
allow_disposable_emails: true,
allow_plus_addressing: false
},
disposableDomains: ['custom-temp.com'],
mergeDisposableDomains: false
}
};
Key | Type | Required | Default | Description |
---|---|---|---|---|
rules.allow_disposable_emails | boolean | Yes | – | Blocks disposable domains |
rules.allow_plus_addressing | boolean | Yes | – | Blocks plus-addressed emails |
disposableDomains | string[] | No | Built-in list | Custom domains to block |
trustedDomains | string[] | No | undefined | Emails/domains to allow regardless of rules |
mergeDisposableDomains | boolean | No | true | Whether to merge custom domains with built-in list |
The mergeDisposableDomains
option controls how your custom disposableDomains
list is handled:
true
(default): Your custom domains are added to the built-in listfalse
: Only your custom domains are used (built-in list is ignored)// Example: Merge with built-in list (recommended)
{
production: {
rules: { allow_disposable_emails: false, allow_plus_addressing: false },
disposableDomains: ['company-temp.com'],
mergeDisposableDomains: true // Blocks both built-in domains AND company-temp.com
}
}
// Example: Use only custom domains
{
production: {
rules: { allow_disposable_emails: false, allow_plus_addressing: false },
disposableDomains: ['company-temp.com'],
mergeDisposableDomains: false // Only blocks company-temp.com (allows 10minutemail.com, etc.)
}
}
new DisposableEmailValidator(environment: string, config: DisposableEmailValidatorConfig)
environment
: the name of any environment defined in your config (e.g., production
, development
, staging
, my-custom-env
, etc.)config
: your full multi-environment configuration objectvalidateEmail(email: string): ValidationResult
Returns:
{ success: true, error: null }
// or
{ success: false, error: string }
'Invalid email format'
'Disposable email addresses are not allowed'
'Plus addressing is not allowed'
If disposableDomains
is not provided, this package includes a prebuilt list from disposable-email-domains.
You get coverage for thousands of known throwaway providers out of the box.
MIT — LICENSE
Pull requests are welcome! If you'd like to add a feature, fix a bug, or improve documentation:
git checkout -b feature/my-feature
)git commit -am 'Add feature'
)git push origin feature/my-feature
)Made with ❤️ by Wilson Adenuga - @Adenugawilson - oluwatunmiseadenuga@gmail.com
If you find this package useful, please consider ⭐ starring the repository on GitHub! It helps others discover the project and motivates continued development.
1.1.0
FAQs
Block disposable emails with environment-specific rules and plus addressing validation
The npm package disposable-email-validator receives a total of 625 weekly downloads. As such, disposable-email-validator popularity was classified as not popular.
We found that disposable-email-validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.