How I Built a Personalized Email Generator in Python (as a Beginner)

How I Built a Personalized Email Generator in Python (as a Beginner) I’m learning Python as part of my transition into technical writing, and I wanted to build something small but useful. A lot of real-world apps involve user info and email formatting, so I made a script that: Takes a user's full name Generates a clean, formatted email Sends a friendly welcome message This helped me practice functional thinking, input handling, and error catching—all wrapped in a beginner-friendly way. The Core Function Here’s the function that does the main work: def generate_user_info(full_name: str, domain: str = "example.com") -> dict: """ Generates an email and a personalized message based on the full name. """ name_parts = full_name.strip().split() if len(name_parts)

Apr 20, 2025 - 21:11
 0
How I Built a Personalized Email Generator in Python (as a Beginner)

How I Built a Personalized Email Generator in Python (as a Beginner)

I’m learning Python as part of my transition into technical writing, and I wanted to build something small but useful. A lot of real-world apps involve user info and email formatting, so I made a script that:

  • Takes a user's full name
  • Generates a clean, formatted email
  • Sends a friendly welcome message

This helped me practice functional thinking, input handling, and error catching—all wrapped in a beginner-friendly way.

The Core Function

Here’s the function that does the main work:

def generate_user_info(full_name: str, domain: str = "example.com") -> dict:
    """
    Generates an email and a personalized message based on the full name.
    """
    name_parts = full_name.strip().split()

    if len(name_parts) < 2:
        raise ValueError("Please enter both first and last name.")

    first_name = name_parts[0].capitalize()
    last_name = name_parts[-1].lower()
    email = f"{first_name.lower()}.{last_name}@{domain}"
    message = f"Hello {first_name}, your new email is {email}. Welcome aboard!"

    return {
        "name": full_name,
        "email": email,
        "message": message
    }

Making It Interactive

Then I wrapped it in a script so the user can interact with it from the terminal:

def interactive_user_info():
    """
    Collect a user's full name, generate their email, and print a welcome message.
    """
    print("Welcome to the Email Generator!")
    full_name = input("Please enter your full name (e.g., John Doe): ")

    try:
        result = generate_user_info(full_name)
        print("\n✅ Success!")
        print(f"Name   : {result['name']}")
        print(f"Email  : {result['email']}")
        print(f"Message: {result['message']}")
    except ValueError as ve:
        print(f"\n⚠️ Error: {ve}")

if __name__ == "__main__":
    interactive_user_info()

What I Learned

  • Functions help keep logic clean and reusable
  • input() makes scripts interactive, even for beginners
  • Error handling with try/except makes things more user-friendly
  • This project helped me feel like a developer and a writer.
  • This kind of small, real-world project helps me build confidence in both code and communication.

What I’d Add Next

  • Letting users choose the domain
  • Supporting names with middle initials
  • Writing results to a .txt file

Written by a linguist and writing tutor learning Python to build a more flexible life.