Random email generator using python
by specter - Saturday June 24, 2023 at 04:03 AM
#1
import random
import string
import csv
import progressbar

'''
Asks user for how many emails they want generated. Must be Integer.
If not an integer, keeps recursively cycling back until it gets an integer.
'''
def getcount():
    rownums = input("How many email addresses?: ")
    try:
        rowint = int(rownums)
        return rowint
   except ValueError:
        print ("Please enter an integer value")
        return getcount()

'''
Creates a random string of digits between 1 and 20 characters alphanumeric and adds it to a fake domain and fake extension
Most of these emails are completely bogus (eg - gmail.gov) but will meet formatting requirements for my purposes
'''
def makeEmail():
    extensions = ['com','net','org','gov']
    domains = ['gmail','yahoo','comcast','verizon','charter','hotmail','outlook','frontier']

    winext = extensions[random.randint(0,len(extensions)-1)]
    windom = domains[random.randint(0,len(domains)-1)]

    acclen = random.randint(1,20)

    winacc = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(acclen))

    finale = winacc + "@" + windom + "." + winext
    return finale

#save count to var
howmany = getcount()

#counter for While loop
counter = 0

#empty array for loop
emailarray = []

#uses counter to figure out how many emails to keep making

print ("Creating email addresses...")
print ("Progress: ")

prebar = progressbar.ProgressBar(maxval=int(howmany))

for i in prebar(range(howmany)):
    while counter < howmany:
        emailarray.append(str(makeEmail()))
        counter = counter+1
        prebar.update(i)

print ("Creation completed.")

for i in emailarray:
    print(i)
Reply
#2
(Jun 24, 2023, 04:03 AM)specter Wrote: import random
import string
import csv
import progressbar

'''
Asks user for how many emails they want generated. Must be Integer.
If not an integer, keeps recursively cycling back until it gets an integer.
'''
def getcount():
    rownums = input("How many email addresses?: ")
    try:
        rowint = int(rownums)
        return rowint
   except ValueError:
        print ("Please enter an integer value")
        return getcount()

'''
Creates a random string of digits between 1 and 20 characters alphanumeric and adds it to a fake domain and fake extension
Most of these emails are completely bogus (eg - gmail.gov) but will meet formatting requirements for my purposes
'''
def makeEmail():
    extensions = ['com','net','org','gov']
    domains = ['gmail','yahoo','comcast','verizon','charter','hotmail','outlook','frontier']

    winext = extensions[random.randint(0,len(extensions)-1)]
    windom = domains[random.randint(0,len(domains)-1)]

    acclen = random.randint(1,20)

    winacc = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(acclen))

    finale = winacc + "@" + windom + "." + winext
    return finale

#save count to var
howmany = getcount()

#counter for While loop
counter = 0

#empty array for loop
emailarray = []

#uses counter to figure out how many emails to keep making

print ("Creating email addresses...")
print ("Progress: ")

prebar = progressbar.ProgressBar(maxval=int(howmany))

for i in prebar(range(howmany)):
    while counter < howmany:
        emailarray.append(str(makeEmail()))
        counter = counter+1
        prebar.update(i)

print ("Creation completed.")

for i in emailarray:
    print(i)

THANKS!!!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Useful links for developers Manfruity 36 2,353 Apr 24, 2026, 06:54 PM
Last Post: Weirdtatsum30777
  ⭐ Sektor7 - All courses (6 in total) ⭐ red_dot 599 38,579 Apr 23, 2026, 09:51 PM
Last Post: cwel321
  Discord Token Grabber | Private Stealer | Leaked For Free Piplup 351 57,828 Apr 21, 2026, 11:51 PM
Last Post: OldeChicago93
  WEBSITES FOR FREE INSTAGRAM FOLLOWERS ⭐ UHQ Moneygain 101 10,432 Feb 10, 2026, 03:02 PM
Last Post: onionX232
  How to buy crypto without KYC Manfruity 40 2,162 Feb 09, 2026, 10:55 PM
Last Post: Stevemox2

Forum Jump:


 Users browsing this forum: 1 Guest(s)