Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Email Agent (Python CLI)

This small agent composes emails using an LLM (OpenAI) and sends them via SMTP after confirmation.

Requirements

  • Python 3.8+
  • An OpenAI API key
  • SMTP credentials (Gmail app password or other SMTP server)

Install

  1. Copy .env.example to .env and fill your values.
  2. Create a virtualenv and install deps:
    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt

Configure

  • In .env set:
    • OPENAI_API_KEY
    • SMTP_SERVER (e.g., smtp.gmail.com)
    • SMTP_PORT (587)
    • SMTP_USER (your email)
    • SMTP_PASSWORD (app password or SMTP password)
    • FROM_NAME (optional)
    • FROM_EMAIL (optional, defaults to SMTP_USER)
    • DEFAULT_SIGNATURE (optional)

Run examples

  • Compose and send (interactive confirmation):

    python agent.py --to recipient@example.com --instruction "Write a short follow-up to our meeting yesterday and propose next steps."
  • Compose and auto-send (no confirmation — use carefully):

    python agent.py --to recipient@example.com --instruction "Please schedule a 30-minute sync next week" --auto
  • Compose only, do not send:

    python agent.py --to recipient@example.com --instruction "Draft an apology email for a delayed reply" --no-send

Logs

  • Sent/attempted emails are appended to sent_log.jsonl.

Security notes

  • Be careful with storing SMTP passwords in plaintext. For Gmail, prefer App Passwords or OAuth flow for production.
  • The script will present the draft and request confirmation by default; do not use --auto without understanding risks.

Next steps and improvements

  • Add support for attachments.
  • Support OAuth2 for Gmail (instead of password).
  • Add a small web UI (FastAPI + simple frontend) for convenience.
  • Use streaming LLM responses and a more robust JSON schema + validation (Pydantic).
  • Add safety checks / allowed recipient lists for automated sending.

If you want, I can:

  • Add Gmail OAuth flow instead of SMTP passwords.
  • Build a web UI (FastAPI) where you can type instructions and preview/send emails.
  • Add attachments and templates support.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages