├── README.md └── FakeRandomEmails.py /README.md: -------------------------------------------------------------------------------- 1 | # Fake-Email-Generator 2 | A simple python script to generate many fake email addresses on the fly and save them to a CSV file for testing 3 | -------------------------------------------------------------------------------- /FakeRandomEmails.py: -------------------------------------------------------------------------------- 1 | '''make sure you pip install progressbar''' 2 | 3 | 4 | import random 5 | import string 6 | import csv 7 | import progressbar 8 | 9 | ''' 10 | Asks user for how many fake emails they want generated. Must be Integer. Duh. 11 | If not an integer, keeps recursively cycling back until it gets an integer. 12 | ''' 13 | def getcount(): 14 | rownums = input("How many fake email addresses?: ") 15 | try: 16 | rowint = int(rownums) 17 | return rowint 18 | except ValueError: 19 | print ("Please enter an integer value") 20 | return getcount() 21 | 22 | ''' 23 | Creates a random string of digits between 1 and 20 characters alphanumeric and adds it to a fake domain and fake extension 24 | Most of these emails are completely bogus (eg - gmail.gov) but will meet formatting requirements for my purposes 25 | ''' 26 | def makeEmail(): 27 | extensions = ['com','net','org','gov'] 28 | domains = ['gmail','yahoo','comcast','verizon','charter','hotmail','outlook','frontier'] 29 | 30 | winext = extensions[random.randint(0,len(extensions)-1)] 31 | windom = domains[random.randint(0,len(domains)-1)] 32 | 33 | acclen = random.randint(1,20) 34 | 35 | winacc = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(acclen)) 36 | 37 | finale = winacc + "@" + windom + "." + winext 38 | return finale 39 | 40 | #save count to var 41 | howmany = getcount() 42 | 43 | #counter for While loop 44 | counter = 0 45 | 46 | #empty array for loop 47 | emailarray = [] 48 | 49 | #uses counter to figure out how many emails to keep making 50 | 51 | print ("Creating email addresses...") 52 | print ("Progress: ") 53 | 54 | prebar = progressbar.ProgressBar(maxval=int(howmany)) 55 | 56 | for i in prebar(range(howmany)): 57 | while counter <= howmany: 58 | emailarray.append(str(makeEmail())) 59 | counter = counter+1 60 | prebar.update(i) 61 | 62 | print ("Creation completed.") 63 | 64 | #user input for filename. Can even take in a file path, pending you have permission to write there 65 | filename = input("name your file: ") 66 | 67 | ''' 68 | Acutally writes to file here. 69 | uses WA which will write and append the file. If the file doesn't exist, this will create it. 70 | Will write email addresses to array one per row which is why the array is important. 71 | Once complete, will close the file. 72 | ''' 73 | print ("Progress: ") 74 | 75 | bar = progressbar.ProgressBar(maxval=int(howmany)) 76 | 77 | emailfile = open(str(filename), 'w') 78 | aa = csv.writer(emailfile) 79 | for emailaddr in bar(emailarray): 80 | aa.writerow([emailaddr]) 81 | bar.update() 82 | emailfile.close() 83 | 84 | print ("File '" + filename + "' created.") 85 | --------------------------------------------------------------------------------