ULG2 - Email Assistant Workflow - Email Server API URL

Hi, everyone!

In UGL2, there are some files, including utils.py, that summos an email serve API URL as an environmental variable:

image

As it seens, it’s where are the email examples explored in the lab. However, I couldn’t find more information of where to get this API.

Can anyone help in this?

The email service is not an external third-party API. It is a mock email server simulated locally inside your lab environment.

If you are running the lab on the Coursera platform, the environment variable M3_EMAIL_SERVER_API_URL is pre-configured to point to this background service. If it is returning None, restart the kernel via Kernel → Restart Kernel and Clear All Outputs… and run the cells from the top.

If you are running the lab locally on your machine, you must spin up the mock server and configure the environment variable yourself:

  1. Install required dependencies:
    FastAPI requires email-validator to parse email addresses in the schema. Install it in your environment:

    pip install email-validator
    
  2. Start the mock email server:
    Navigate to the M3_UGL_2 directory in your terminal and start uvicorn:

    uvicorn email_server.email_service:app --reload --port 8000
    

    This starts the API endpoints (like /emails, /send) at http://127.0.0.1:8000.

  3. Configure the environment variable:
    Create a .env file in your M3_UGL_2 directory and set the API URL:

    M3_EMAIL_SERVER_API_URL=http://127.0.0.1:8000
    

    Or set it directly in your notebook before importing utils:

    import os
    os.environ["M3_EMAIL_SERVER_API_URL"] = "http://127.0.0.1:8000"