Random Email Generator with Domain Selection

  • Share this:

Code introduction


This function generates a random email address, including the username and domain parts. The username is randomly generated, and the domain is one of the predefined common email service providers.


Technology Stack : Python, Mimesis

Code Type : Function

Code Difficulty : Intermediate


                
                    
def generate_random_user_email():
    import random
    from mimesis import Internet

    email_provider = random.choice(['gmail.com', 'yahoo.com', 'outlook.com', 'hotmail.com', 'aol.com'])
    email_name = Internet().email()
    return f"{email_name}@{email_provider}"                
              
Tags: