Skip to content

Latest commit

Β 

History

286 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“§ MailMind

Your Email System Can Finally Do Jobs For You!

Version Status License Python Node

An AI-powered email agent that combines large language models with modern email system.

Main Interface

MailMind helps you read, organize, draft, and manage emails through an intuitive chat interface.

Quick Start β€’ Features β€’ Contacts β€’ Documentation β€’ Contributing β€’ δΈ­ζ–‡ζ–‡ζ‘£


πŸŽ‰ What's New in v0.0.5

πŸ“š Knowledge Base & Temporary File Upload

We've added powerful file management capabilities to enhance your AI experience!

Knowledge Base Feature:

  • πŸ“ Document Management - Upload, create, edit, and delete knowledge documents
  • πŸ“„ Multi-Format Support - Supports .txt, .md, .docx, .pdf, and .doc files
  • πŸ”„ Auto Conversion - .docx, .pdf, and .doc files automatically converted to .md for AI compatibility
  • ✏️ In-App Editing - Edit .txt and .md files directly in the browser
  • 🎯 Persistent Context - Knowledge base files are always accessible to AI across all sessions

Temporary File Upload:

  • πŸ’¬ Session-Specific Files - Upload files specific to each chat session
  • πŸ“‚ Agent Filesystem Access - Files are stored in agent's filesystem at temp_uploads/
  • πŸ”§ Tool Integration - AI can read and process uploaded files using file tools
  • πŸš€ Instant Availability - Files immediately available without agent reload
  • πŸ—‘οΈ Easy Management - Delete temporary files with one click

How It Works:

Knowledge Base:

  1. Navigate to the Knowledge page
  2. Upload documents (.txt, .md, .docx, .pdf, .doc) or create new text files
  3. Edit content directly in the browser
  4. AI automatically has access to all knowledge base documents

Temporary Files (Chat):

  1. In the Chat page, click the Add File button next to the input box
  2. Select a file to upload (max 10MB, same formats as knowledge base)
  3. File appears as a tag above the input box
  4. AI can access the file via its filesystem tools during the session

✨ Features

πŸ€– AI-Powered Email Agent

  • Natural language interaction
  • Context-aware responses
  • Intelligent email processing
  • Automated workflows with smart planning

πŸ“§ Intelligent Email Box

  • Read, compose, send emails
  • Organize emails by AI
  • Extract information by intuition
  • Generate communication flows

πŸ‘₯ AI-accessable Contacts

  • Create and edit contacts
  • Automatically organize by AI
  • AI-understood social networks
  • Powerful search and filtering

πŸ” Smart Capabilities

  • Web search integration
  • Multi-session support
  • Real-time streaming
  • Attachment handling

πŸ“š Knowledge Base

  • Upload & manage documents
  • Multi-format support (.txt, .md, .docx, .pdf, .doc)
  • Auto conversion to .md
  • In-app editing for text files
  • Global AI access across sessions

πŸ“Ž Temporary File Upload

  • Session-specific file uploads
  • Agent filesystem integration
  • Files accessible via tools
  • Instant availability
  • Easy file management

πŸ—οΈ Architecture

Backend Stack

FastAPI    β†’ High-performance async web framework
LangGraph  β†’ Advanced agent orchestration
WebSocket  β†’ Real-time bidirectional communication
IMAP/SMTP  β†’ Direct email protocol integration

Frontend Stack

React 18      β†’ Modern UI with hooks
TypeScript    β†’ Type-safe development
Tailwind CSS  β†’ Utility-first styling
Vite          β†’ Lightning-fast build tool
Axios         β†’ HTTP & WebSocket client

AI Integration

  • OpenAI-Compatible APIs - Support for multiple LLM providers
  • Tavily Search - Web search capabilities
  • Subagent Architecture - Specialized task handling
  • Context Management - Smart conversation tracking

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Python 3.10+
  • Email account with IMAP access (Gmail recommended)
  • API keys for your chosen LLM provider

Installation

1. Clone the repository
git clone https://github.com/yourusername/mailmind.git
cd mailmind
2. Configure environment variables
cd web_app
cp .env.example .env
# Edit .env with your API keys and email credentials
3. Start the application
./start.sh

The startup script will automatically:

  • βœ… Install Python dependencies in a virtual environment
  • βœ… Install Node.js dependencies
  • βœ… Start the backend server (default: http://localhost:2821)
  • βœ… Start the frontend dev server (default: http://localhost:2922)
4. Open your browser

Navigate to http://localhost:2922 and start managing your emails with AI!

βš™οΈ Configuration

Model Settings

Variable Description Example
MODEL Model name gpt-4, claude-3-sonnet
OPENAI_API_KEY Your API key sk-...
OPENAI_BASE_URL API endpoint https://api.openai.com/v1
DISPLAY_REASONING Show reasoning True/False

Email Settings

Variable Description Default
USERNAME Your email address -
PASSWORD App-specific password -
IMAP_SERVER IMAP server address imap.gmail.com
SMTP_SERVER SMTP server address smtp.gmail.com
IMAP_PORT IMAP port 993
SMTP_PORT SMTP port 465

Tested Email Providers

Provider Status Notes
βœ… Gmail Fully Tested & Supported Requires App Password. Enable IMAP in settings.
πŸ”„ Outlook In Testing Very complicated access through IMAP and SMTP protocols.
Gmail Setup Guide (Recommended)
  1. Enable 2-Factor Authentication

    • Go to Google Account settings
    • Security β†’ 2-Step Verification
    • Enable 2FA
  2. Generate App Password

    • Go to Google Account settings
    • Security β†’ App passwords
    • Generate new app password
    • Use this password in PASSWORD field
  3. Enable IMAP Access

    • Go to Gmail settings
    • Forwarding and POP/IMAP
    • Enable IMAP
    • Save changes
  4. Configure MailMind

    USERNAME=yourname@gmail.com
    PASSWORD=[your 16-character app password]
    IMAP_SERVER=imap.gmail.com
    SMTP_SERVER=smtp.gmail.com
    IMAP_PORT=993
    SMTP_PORT=465
    

Network Settings

Variable Description Default
BACKEND_PORT Backend server port 2821
FRONTEND_PORT Frontend dev server port 2922

πŸ’‘ Usage

Chat Interface

  1. Start a Conversation - Type your request in natural language:

    "Summarize my unread emails"
    "Reply to all unread New Year greeting emails"
    "Delete all emails from newsletter@example.com"
    
  2. Watch the AI Work - See the agent's thought process and tool calls in real-time

  3. Manage Multiple Sessions - Create new chat sessions for different tasks

Email Management

Action Description
πŸ“– Read Fetch and display emails with filtering
βœ‰οΈ Send Compose and send new emails
πŸ—‘οΈ Delete Remove unwanted emails
πŸ“ Move Organize emails into folders
🏴 Flag Mark as important/unread
πŸ“Ž Attachments View and download files

Contacts Management

Organize your contacts efficiently with our comprehensive contacts feature:

Feature Description
πŸ‘€ Add Contacts Create new contacts with multiple email addresses
✏️ Edit Contacts Update contact information anytime
πŸ—‘οΈ Delete Contacts Remove contacts with confirmation
🏷️ Groups Organize contacts into custom groups
πŸ” Search Find contacts by name, email, or group
πŸ“‹ Alphabetical View Contacts automatically sorted by first letter

Benefits:

  • πŸ“§ Quick access when composing emails
  • 🎯 Filter emails by contacts
  • πŸ‘₯ Organize contacts into groups (Family, Work, Friends, etc.)
  • πŸ”Ž Search across all contact fields instantly

Settings Page

Configure everything through the web UI:

  • πŸ”‘ Update API keys
  • πŸ“§ Configure email servers
  • πŸ”Œ Adjust network ports
  • 🎨 Toggle display options

Contacts Page

Manage your network of contacts efficiently:

Adding Contacts:

  1. Click the "Add Contact" button
  2. Enter contact name (required)
  3. Add one or more email addresses
  4. Assign to groups (e.g., Family, Work, Friends)
  5. Save the contact

Organizing with Groups:

  • Create custom groups to categorize contacts
  • Filter contacts by group in the sidebar
  • Groups show contact counts
  • Easily add/remove contacts from groups

Searching Contacts:

  • Search by name, email, or group
  • Real-time filtering as you type
  • Alphabetically sorted display
  • Quick access to contact details

Managing Contacts:

  • ✏️ Edit any contact to update information
  • πŸ—‘οΈ Delete with confirmation dialog
  • πŸ“§ Multiple email addresses per contact
  • 🏷️ Visual group tags on each contact

πŸ“ Project Structure

mailmind/
β”œβ”€β”€ deepagents/              # Core agent framework
β”‚   β”œβ”€β”€ backends/           # Backend implementations
β”‚   β”œβ”€β”€ middleware/         # Agent middleware
β”‚   └── ...
β”œβ”€β”€ lib/                    # Shared utilities
β”‚   β”œβ”€β”€ email_tools.py     # Email operations
β”‚   β”œβ”€β”€ prompt.py          # System prompts
β”‚   └── ...
β”œβ”€β”€ web_app/               # Web application
β”‚   β”œβ”€β”€ backend/          # FastAPI server
β”‚   β”‚   β”œβ”€β”€ api_server.py
β”‚   β”‚   └── requirements.txt
β”‚   β”œβ”€β”€ frontend/         # React + TypeScript UI
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ components/   # UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ pages/        # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ lib/          # API & utilities
β”‚   β”‚   β”‚   └── contexts/     # React contexts
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   └── vite.config.js
β”‚   └── start.sh         # Startup script
β”œβ”€β”€ .env.example          # Environment template
└── README.md            # This file

πŸ› οΈ Development

Backend Development

cd web_app/backend
source venv/bin/activate  # Activate virtual environment
python api_server.py      # Start with auto-reload

Frontend Development

cd web_app/frontend
npm run dev     # Start dev server with hot reload
npm run build   # Build for production
npm run preview # Preview production build

Quick Development of Agent

python lib/test.py

πŸ”‘ Key Features Explained

Session Isolation

Each chat session maintains:

  • βœ… Separate agent instance with isolated state
  • βœ… Independent email cache
  • βœ… Dedicated filesystem for file operations
  • βœ… Unique conversation history

Real-Time Streaming

  • βœ… WebSocket connection for instant communication
  • βœ… Stream agent responses token-by-token
  • βœ… Display tool calls and results as they happen
  • βœ… Visual feedback for agent status

Email Cache Persistence

  • βœ… Caches persisted to .emails_cache.json
  • βœ… Survives server restarts
  • βœ… Automatically cleaned up on session deletion
  • βœ… Session-isolated to prevent cross-contamination

πŸ”§ Troubleshooting

Email Connection Issues

Gmail-specific issues
  • Use an App Password instead of your regular password
  • Enable IMAP access in Gmail settings
  • Check "Less secure app access" if applicable
  • Verify 2FA is enabled (required for App Passwords)
General email issues
  • Check firewall/proxy settings if using a proxy
  • Verify IMAP/SMTP server addresses and ports
  • Ensure ports 993 (IMAP) and 465/587 (SMTP) are open
  • Test connection with telnet imap.gmail.com 993

API Errors

Common API issues
  • Verify API key is valid and has sufficient credits
  • Check that OPENAI_BASE_URL is correct for your provider
  • Some providers require specific model names
  • Check rate limits and quota usage
  • Review error messages in backend logs

WebSocket Connection

Connection problems
  • Ensure backend is running and accessible
  • Check port conflicts in .env
  • Verify browser console for errors
  • Try refreshing the page
  • Check network tab in browser DevTools

Performance Issues

Slow performance
  • Reduce email batch size in read_emails tool
  • Close unused chat sessions
  • Clear browser cache if UI is slow
  • Check system resources (CPU, memory)
  • Monitor network tab for large payloads

πŸ”’ Security Considerations

⚠️ Important Security Notes:

  • ❌ Never commit .env file to version control
  • πŸ”‘ Use App Passwords for email authentication
  • πŸ”„ Keep API keys secure and rotate regularly
  • ⚠️ Be cautious with proxy configurations
  • 🌐 The app runs locally; avoid exposing ports to the internet
  • πŸ“ Check .gitignore to ensure sensitive files are excluded

πŸ“ TODO List

  • Email Box - Intelligent email client interface
  • User File Upload - Upload files for AI chat βœ… (v0.0.5)
  • Long-term Memory - Store and retrieve conversation facts
  • Advanced Search - AI-powered categorization
  • Multi-Account Support - Multiple email accounts
  • Email Analytics - Statistics dashboard
  • AI Summaries - Thread summarization
  • Calendar Integration - Google Calendar & Outlook
  • More LLM APIs - Anthropic, Cohere, etc.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ™ Acknowledgments

Built with amazing open-source tools:

πŸ’¬ Support

For issues and questions:


Built with ❀️ by the MailMind team

⬆ Back to Top

About

LLM-powered email agent for tackling long-horizon tasks with planning, computer access, and sub-agent delegation

Resources

Stars

17 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages