No description
  • Rust 50.4%
  • TypeScript 30.9%
  • JavaScript 14.9%
  • HTML 1.4%
  • CSS 1.1%
  • Other 1.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Yi-Hua Liang 29049a1ddc
Some checks failed
Docker Publish / build-frontend (push) Has been cancelled
Docker Publish / build-backend (aarch64-unknown-linux-gnu) (push) Has been cancelled
Docker Publish / build-backend (x86_64-unknown-linux-gnu) (push) Has been cancelled
Docker Publish / build-docker (push) Has been cancelled
Docker Publish / deploy (push) Has been cancelled
feat: implement Cloudflare cache purge functionality and update documentation
- Added environment variables for Cloudflare zone ID and API token in .env.example.
- Enhanced GitHub Actions workflow to purge Cloudflare cache after deployment.
- Introduced new documentation for Cloudflare cache purge operations.
- Updated README files to include links to the new documentation.
- Added cache purge feature in the Dashboard page with user interface for selecting purge targets.
- Modified finance analysis page to support collapsible cards for better user experience.
- Updated internationalization files to include new cache purge related strings.
2026-04-26 05:44:14 +08:00
.agents/workflows feat: initialize project scaffolding for AI Mail Butler with core modules, Docker configuration, and initial specifications 2026-04-18 12:27:24 +08:00
.cargo feat: add pre-commit and requirements review workflows, update NERDCTL compose guide, and enhance user model with email format and assistant details 2026-04-20 11:58:22 +08:00
.github feat: implement Cloudflare cache purge functionality and update documentation 2026-04-26 05:44:14 +08:00
.vscode feat: implement email processing rules management, including creation, updating, and toggling of rules based on user input 2026-04-21 22:39:23 +08:00
browser-extension feat: add packaging and download instructions for browser extension 2026-04-26 00:47:21 +08:00
docs feat: implement Cloudflare cache purge functionality and update documentation 2026-04-26 05:44:14 +08:00
frontend feat: implement Cloudflare cache purge functionality and update documentation 2026-04-26 05:44:14 +08:00
src feat: implement Cloudflare cache purge functionality and update documentation 2026-04-26 05:44:14 +08:00
.dockerignore feat: initialize project scaffolding for AI Mail Butler with core modules, Docker configuration, and initial specifications 2026-04-18 12:27:24 +08:00
.env.example feat: implement Cloudflare cache purge functionality and update documentation 2026-04-26 05:44:14 +08:00
.gitignore feat: add packaging and download instructions for browser extension 2026-04-26 00:47:21 +08:00
About.md feat: add author and project intent sections to documentation, and update CI to prefer GITHUB_SHA for commit tracking 2026-04-24 05:51:08 +08:00
About.zh-TW.md feat: add author and project intent sections to documentation, and update CI to prefer GITHUB_SHA for commit tracking 2026-04-24 05:51:08 +08:00
build.rs feat: add author and project intent sections to documentation, and update CI to prefer GITHUB_SHA for commit tracking 2026-04-24 05:51:08 +08:00
build_all.sh feat: add M365 OAuth environment variables, optimize build script for cross-platform compatibility, and remove unused mail module imports. 2026-04-18 14:10:48 +08:00
Cargo.lock feat(cli): add CLI debug mode for processing .eml files 2026-04-23 06:14:20 +08:00
Cargo.toml feat(cli): add CLI debug mode for processing .eml files 2026-04-23 06:14:20 +08:00
docker-compose.yml feat: implement email error retry functionality and update deployment configurations 2026-04-22 21:02:01 +08:00
DOCKER_AWS_GUIDE.md feat: implement mail error logging and admin error retrieval in the application 2026-04-21 14:24:39 +08:00
DOCKER_AWS_GUIDE.zh-TW.md feat: implement mail error logging and admin error retrieval in the application 2026-04-21 14:24:39 +08:00
Dockerfile feat: initialize React frontend project with Vite and TypeScript configuration 2026-04-18 12:56:57 +08:00
LICENSE feat: initialize project scaffolding for AI Mail Butler with core modules, Docker configuration, and initial specifications 2026-04-18 12:27:24 +08:00
PRE_COMMIT_REPORT.md feat: enhance user preferences with time/date formats and i18n support across multiple components 2026-04-24 05:22:34 +08:00
README.md feat: implement Cloudflare cache purge functionality and update documentation 2026-04-26 05:44:14 +08:00
README.zh-TW.md feat: implement Cloudflare cache purge functionality and update documentation 2026-04-26 05:44:14 +08:00
requirements.md feat: add magic link authentication, M365 OAuth documentation, and example domain updates 2026-04-18 14:03:28 +08:00
test_samotop.rs feat: add magic link authentication, M365 OAuth documentation, and example domain updates 2026-04-18 14:03:28 +08:00
test_smtp_local.py feat: update default recipient email address in SMTP test script 2026-04-22 00:05:08 +08:00
TODO.md feat: enhance user preferences with time/date formats and i18n support across multiple components 2026-04-24 05:22:34 +08:00
TODO.zh-TW.md feat: enhance user preferences with time/date formats and i18n support across multiple components 2026-04-24 05:22:34 +08:00

AI Mail Butler

AI Mail Butler is a self-hosted email processing assistant platform. It consists of a dedicated Mail Server and a Web-based GUI. Users forward selected emails from their own mail servers to the assistant's mailbox. The assistant intelligently identifies the forwarding user, onboards new users via email inquiry, performs AI-driven actions (e.g., translation, auto-reply), and provides a transparent web dashboard for monitoring all processed emails and actions.

About the Author and Project Intent

For background on the creator, project motivation, and open collaboration notes:

System Architecture

  • Backend: Rust (tokio, axum)
  • Database: SQLite (via sqlx)
  • AI Integration: Custom LLM endpoints via HTTP (reqwest)
  • Mail Handling: SMTP receiving (Samotop) and sending (mail-send) with MIME/HTML support
  • Reliability: Automated startup diagnostics and database self-healing mechanisms

Features

  • Email forwarding detection & parsing: Identifies the original user who forwarded the email.
  • AI processing module: English to Traditional Chinese translation, rule-based auto-reply.
  • AI Chat Interface: Converse directly with your email assistant via the Web UI. Anonymous visitors can also chat with the AI to learn about the system. Features detailed chat stats (token count and generation speed).
  • Document-Grounded Answers: The chat assistant can retrieve relevant content from project documentation and answer with context from matched docs.
  • Documentation Cache Index: Documentation lookup uses an in-memory cache index with periodic refresh, reducing repeated disk scans while keeping answers current.
  • Chat-Driven Rule Creation: When users ask in chat to add processing behavior, the assistant can extract and create new email rules automatically (with dedup protection).
  • Long-term Memory: The AI assistant maintains memory of past interactions to provide more personalized and context-aware responses.
  • Interactive Onboarding: New users are guided through a series of onboarding questions to set up their preferences and assistant identity.
  • Custom AI Persona: Users can define their assistant's Chinese and English names, as well as its reply tone (e.g., professional, friendly).
  • Behavioral Analytics: Automatically tracks user activity and repetitive questions to provide insights for assistant optimization.
  • User configuration & onboarding: Automated onboarding flow via email.
  • Role-Based Access Control (RBAC): Supports Admin, User, and Anonymous roles with strict data isolation.
  • Passwordless Authentication: Magic link login via email (supports Plain Text & HTML Rich Text, bilingual).
  • User Settings: Toggle Auto-reply and Dry Run mode (AI replies sent to yourself for review before going to external senders).
  • Web Dashboard: View history of received emails and actions taken, featuring an Apple-style aesthetic inspired by Ant Design.
  • Built-in SMTP: Lightweight Rust-native SMTP server for easy deployment.
  • Diagnostics: Self-healing database schema verification on startup.
  • Readonly Overlay Mode: Run the application against a data snapshot without modifying it. All writes go to a separate overlay directory; reads transparently fall back to the base snapshot. Useful for demo, staging, and read-only mirror deployments.

Development and Testing

Prerequisites

  • Rust (cargo)

Build

cargo build

Run

cargo run

CLI Debug Mode (No Backend Server)

Use CLI mode to process local .eml files from the spool directory without starting SMTP/Web servers.

Single pass (default):

cargo run -- --mode cli

Custom spool directory + JSON report output:

cargo run -- --mode cli --spool-dir data/mail_spool --report-json data/mail_spool/cli-report.json

Keep source .eml files in place for repeated debugging:

cargo run -- --mode cli --keep-files

Watch mode (continuous processing):

cargo run -- --mode cli --watch

Interactive REPL mode:

cargo run -- --mode cli --repl

REPL commands: list, show <index|path>, process <index|path>, retry-unknown, report, exit.

Process one specific .eml file:

cargo run -- --mode cli --eml-file /absolute/path/to/mail_123.eml --keep-files

Simulate AI agent steps (rules + memory) and print step-by-step status:

cargo run -- --mode cli \
    --eml-file /absolute/path/to/mail_123.eml \
    --simulate-agent --simulate-rules --simulate-memory \
    --as-user [email protected] \
    --step --keep-files

Notes:

  • --simulate-agent enables simulation flow.
  • --simulate-rules checks enabled email_rules and generates a simulated auto-reply preview.
  • --simulate-memory loads user_memories and generates a memory-aware simulated reply preview.
  • --as-user forces a user context for debugging when sender mapping fails.
  • --step prints each processing stage and simulation progress in CLI output.

Optional docs retrieval controls:

  • DOCS_WHITELIST: Comma-separated file names or keywords to allow for AI document references. Example: DOCS_WHITELIST=GMAIL-SMTP-SETUP.md,zh-TW
  • Language preference effect: logged-in users with preferred_language=zh-TW will prioritize matches from *.zh-TW.md documents.

Test

cargo test

Docker Deployment

Build and run in background using Docker Compose:

docker-compose up --build -d

Detailed Deployment Guides (including AWS EC2 implementation):

Cloudflare DNS Configuration (MX Records)

To receive emails at your custom domain using AI Mail Butler, you need to configure your DNS settings. Here is an example of configuring MX records in Cloudflare for mail.example.com:

  1. Log in to your Cloudflare dashboard and select your domain (example.com).
  2. Navigate to the DNS -> Records section.
  3. First, ensure you have an A record pointing to your server's IP address:
    • Type: A
    • Name: mail (or your preferred subdomain)
    • IPv4 address: YOUR_SERVER_IP
    • Proxy status: DNS only (Turn OFF the orange cloud, as Cloudflare proxy only supports HTTP/HTTPS, not SMTP).
  4. Add the MX record to direct emails to your server:
    • Type: MX
    • Name: mail (This means you will receive emails at *@mail.example.com)
    • Mail server: mail.example.com
    • Priority: 10

Once DNS propagates, any email sent to [email protected] will be routed to your AI Mail Butler instance.

SMTP Configuration (Gmail / M365)

To send emails (for Magic Links and AI replies), you need to configure an SMTP relay.

Gmail

Microsoft 365 (M365)

If you use a Microsoft 365 (M365) account to send emails, you have two options:

  1. App Passwords (SMTP AUTH): Easier for small-scale/personal use.
  2. OAuth 2.0 (Microsoft Graph): Recommended for production (required if SMTP AUTH is disabled by your organization).

Readonly Overlay Mode

Run AI Mail Butler against an existing data snapshot without modifying it. All writes are redirected to an overlay directory; spool and file reads transparently fall back to the base snapshot when the overlay doesn't have the file yet. The API is locked to read-only operations for the duration of the session.

Role-Based Access Control (RBAC)

The system supports strict role-based data isolation. For details on configuring an administrator and the permissions for each role, please read the RBAC Documentation.

How It Works — Feature Guide

For a full explanation of the email forwarding workflow, currently supported AI processing capabilities, and the community Feature Wish Wall (vote on what gets built next), see:

License

This software is released under The Unlicense or CC0 1.0 Universal. See the LICENSE file for details.