Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
neeramrutia committed May 7, 2023
0 parents commit 5856589
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 0 deletions.
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
70 changes: 70 additions & 0 deletions GmailListGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const emailValidator = require('email-validator');
const crypto = require('crypto');
const readline = require('readline-sync');
const emailExistence = require('email-existence');
const emoji = require("node-emoji");
const fs = require('fs');

const false_ = emoji.get("x");
const true_ = emoji.get("heavy_check_mark");

let emailProviders = "gmail"
let tlds = "com"

console.log("Enter the length of the email address:");
let emailLength = parseInt(readline.question());

console.log("Enter the number of emails you want to generate:");
let numberOfEmails = parseInt(readline.question());

const generateRandomString = (length) => {
const charset = 'abcdefghijklmnopqrstuvwxyz0123456789.-';
let email = "";
for (let i = 0; i < length; i++) {
email += charset.charAt(Math.floor(Math.random() * charset.length));
}
return email;
}

const generateRandomEmail = async () => {
const possibleLetters = 'abcdefghijklmnopqrstuvwxyz';
let firstLetter = possibleLetters[Math.floor(Math.random() * possibleLetters.length)];
let email = firstLetter + generateRandomString(emailLength-1) + '@' + emailProviders.trim() + '.' + tlds.trim();
if(emailValidator.validate(email)){
const isEmailReal = await checkEmailReal(email);
if(isEmailReal){
return email;
}else{
console.log(`[${false_}] - ${email}`);
return generateRandomEmail();
}
}else{
console.log(`[${false_}] - ${email}`);
return generateRandomEmail();
}
}



const checkEmailReal = (email) => {
return new Promise((resolve, reject) => {
emailExistence.check(email, (error, response) => {
if (error) {
resolve(false);
}else{
resolve(response);
}
});
});
}

for (let i = 0; i < numberOfEmails; i++) {
generateRandomEmail().then(email => {
console.log(`[${true_}] - ${email}`);
fs.appendFile('true_emails.txt', email + '\n', (err) => {
if(err) {
console.log(err);
}
});
});
}
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# GmailListGenerator
A script that generates a specified number of random Gmail email addresses and checks their existence, saving the valid ones to a text file.

## Requirements

- ```email-validator```
- ```crypto```
- ```readline-sync```
- ```email-existence```
- ```node-emoji```
- ```fs```

## Getting Started

- Clone the repository.
- Run npm install to install the required dependencies.
- Run the script by using node scriptName.js in your command line.
- Follow the prompts in the command line to specify the length of the email addresses and the number of emails to generate.
- Valid email addresses will be saved to a file named "true_emails.txt" in the root directory.

## Configuration

The script is currently set to generate email addresses with the "gmail" provider and the "com" top level domain (TLD). If you want to change this, you can edit the following lines in the script:

```
let emailProviders = "gmail"
let tlds = "com"
```

## Notes

The script uses a simple random string generator to create the email addresses, so it is possible that some generated addresses may not be valid even though they pass the email validation check.

73 changes: 73 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
"crypto": "^1.0.1",
"email-existence": "^0.1.6",
"email-validator": "^2.0.4",
"fs": "^0.0.1-security",
"node-emoji": "^1.11.0",
"readline-sync": "^1.4.10"
}
}

0 comments on commit 5856589

Please sign in to comment.