Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexZeitler/1b95a0d8c6a40147eaca4074d7a36c35 to your computer and use it in GitHub Desktop.
Save AlexZeitler/1b95a0d8c6a40147eaca4074d7a36c35 to your computer and use it in GitHub Desktop.
Throw away / disposable email domain list with Postgres import
#!/bin/bash
# download the files
curl -o file1.txt https://gist.githubusercontent.com/ammarshah/f5c2624d767f91a7cbdc4e54db8dd0bf/raw/660fd949eba09c0b86574d9d3aa0f2137161fc7c/all_email_provider_domains.txt
curl -o file2.js.txt https://gist.githubusercontent.com/Evavic44/8348e357935d09f79d4c1616b0c20408/raw/72996e053cbaf39de9cf16d304d2c237184f96d2/domain.js
curl -o file3.txt https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.txt
# remove first and last line, remove quotes, commas and spaces
sed -e '1d;$d' file2.js.txt | awk '{ gsub(/["\, ]/, ""); print }' > file2.txt
# combine the files and remove duplicates
sort -u file1.txt file2.txt file3.txt > merge.txt
# remove empty lines
sed '/^$/d' merge.txt > domain-ban-list.txt
# write number of domains
wc -l domain-ban-list.txt
# create table and import data
docker exec -i <postgres-container> psql -h localhost -U <username> \
--password <password> -d <database> -c \
"DROP TABLE IF EXISTS email_domains; \
CREATE TABLE IF NOT EXISTS email_domains (id SERIAL PRIMARY KEY, domain TEXT); \
COPY email_domains(domain) FROM STDIN;" < ./domain-ban-list.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment