Skip to content

Commit

Permalink
Disallow known throwaway email domains
Browse files Browse the repository at this point in the history
2 data sources with updates.
  • Loading branch information
bcomnes committed Aug 7, 2023
1 parent e4998d9 commit a305b21
Show file tree
Hide file tree
Showing 12 changed files with 13,278 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ updates:
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
interval: "daily"
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
with:
# fetch full history so things like auto-changelog work properly
fetch-depth: 0
submodules: true
- name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "disposable-email-domains"]
path = disposable-email-domains
url = [email protected]:disposable-email-domains/disposable-email-domains.git
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![downloads](https://img.shields.io/npm/dm/resolve-email.svg)](https://npmtrends.com/resolve-email)
[![Socket Badge](https://socket.dev/api/badge/npm/package/resolve-email)](https://socket.dev/npm/package/resolve-email)

Resolve the domain of a syntactically valid email address to see if there is even a chance of deliverability.
Resolve the domain of a syntactically valid email address to see if there is even a chance of deliverability. Also checks against a large list of disposable email address domains and rejects those.

```
npm install resolve-email
Expand All @@ -29,6 +29,11 @@ console.log(results)

This module was adapted from [nodemailer/nodemailer-direct-transport](https://github.com/nodemailer/nodemailer-direct-transport/blob/v3.3.2/lib/direct-transport.js#L438)

The disposable email domain list is generated from the following data sources:

- https://github.com/romainsimon/emailvalid
- https://github.com/disposable-email-domains/disposable-email-domains

## License

MIT
33 changes: 33 additions & 0 deletions build-throwaway-domain-list.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { readFile, writeFile } = require('node:fs/promises')
const { join } = require('node:path')
const emailvalidDomains = require('emailvalid/domains.json')

const disposableEmailDomains = new Set()

const disposableEmailDomainsPath = join(__dirname, 'disposable-email-domains', 'disposable_email_blocklist.conf')

readFile(disposableEmailDomainsPath, { encoding: 'utf-8' })
.then(async data => {
const disposableEmailDomainsRaw = data
const disposableEmailDomainsList = disposableEmailDomainsRaw.split('\n').slice(0, -1)
for (const domain of disposableEmailDomainsList) {
disposableEmailDomains.add(domain)
}
})
.then(async () => {
const disposableOnly = Object.entries(emailvalidDomains).filter(([domain, type]) => type === 'disposable').map(([domain, type]) => domain)

for (const domain of disposableOnly) {
disposableEmailDomains.add(domain)
}
})
.then(async () => {
return await writeFile('disposable.json', JSON.stringify(Array.from(disposableEmailDomains).sort(), null, ' '))
})
.then(async () => {
console.log('done')
})
.catch(err => {
console.error(err)
process.exit(1)
})
1 change: 1 addition & 0 deletions disposable-email-domains
3 changes: 3 additions & 0 deletions disposable.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const disposableArray = require('./disposable.json')

module.exports.disposable = new Set(disposableArray)
Loading

0 comments on commit a305b21

Please sign in to comment.