Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EmailMasterAI - AI-Powered Email Management System

PHP Version License OpenAI Gemini

EmailMasterAI is an intelligent, AI-powered email management system that automates email analysis, reply generation, and email composition. Built with PHP, it integrates seamlessly with multiple AI providers including OpenAI, Google Gemini, Anthropic Claude, DeepSeek, and xAI Grok.

![EmailMasterAI Dashboard](assets/images/Dashboard - EmailMasterAI - AI-Powered Email Assistant.png)

EmailMasterAI Dashboard - Your AI-powered email management interface

🌟 Features

Core Capabilities

  • πŸ“§ Email Loading & Storage - Automatically fetch and store emails from IMAP servers
  • πŸ€– AI-Powered Analysis - Analyze email content, extract insights, and generate summaries
  • ✍️ Smart Reply Generation - Automatically generate professional email replies using AI
  • πŸ“ Email Composition - Create new emails with AI-generated content
  • 🌐 Multi-Language Support - Works with emails in any language (English, Gujarati, Hindi, etc.)
  • ⚑ Background Processing - Non-blocking email loading with real-time progress tracking

AI Provider Support

  • βœ… OpenAI (GPT-4o, GPT-4o-mini, GPT-3.5-turbo)
  • βœ… Google Gemini (Gemini 2.5 Flash, Gemini 2.5 Pro, Gemini 3 Pro)
  • βœ… Anthropic Claude (Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku)
  • βœ… DeepSeek (OpenAI-compatible API)
  • βœ… xAI Grok (Grok-4 and other models)

Technical Features

  • IMAP/SMTP Integration - Works with Gmail, Outlook, Yahoo, and any IMAP/SMTP provider
  • HTML Email Support - Properly renders HTML emails
  • MIME Decoding - Handles encoded email headers and content
  • UTF-8 Encoding - Full support for international characters
  • Error Handling - Comprehensive error handling and validation
  • Security - Secure credential management and input sanitization

πŸš€ Quick Start

Prerequisites

  • PHP 8.3 or higher
  • Web server (Nginx or Apache)
  • PHP extensions: imap, curl, mbstring, iconv
  • AI API key (OpenAI, Gemini, Anthropic, DeepSeek, or Grok)

Installation

  1. Clone the repository:
git clone https://github.com/jasminvdev/emailMasterAi.git
cd emailMasterAI
  1. Install PHP extensions (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install php8.3-imap php8.3-curl php8.3-mbstring php8.3-iconv
sudo phpenmod -v 8.3 imap curl mbstring iconv
sudo systemctl restart php8.3-fpm
  1. Configure the application:
# Copy the example configuration file
cp config.php.example config.php

# Edit config.php with your credentials
nano config.php  # or use your preferred editor

⚠️ Important:

  • The config.php file contains sensitive credentials (API keys, passwords) and is excluded from Git for security
  • You must create config.php from config.php.example and fill in your own credentials
  • The config.php.example file is a template with placeholder values - it will not work until you copy it and configure it
  1. Set permissions:
sudo chown -R www-data:www-data .
sudo chmod -R 755 .
sudo mkdir -p emails
sudo chmod 755 emails
  1. Verify your setup:
http://your-domain/emailMasterAI/test_setup.php

This will check all your configurations and connections. See the Testing & Verification section below for details.

  1. Access the application:
http://your-domain/emailMasterAI/

πŸ“– Configuration

⚠️ Configuration Setup (Required First Step)

Before using EmailMasterAI, you must configure it:

  1. Copy the example configuration file:

    cp config.php.example config.php
  2. Edit config.php with your credentials:

    nano config.php  # or use your preferred editor (vim, code, etc.)
  3. Fill in all required values (see sections below for details)

Why is config.php not in Git?

  • config.php contains sensitive information (passwords, API keys, email credentials)
  • It's excluded from version control for security reasons
  • Each user must create their own config.php from the config.php.example template
  • The example file shows all available configuration options with placeholders

Email Configuration

Edit config.php with your email credentials:

// IMAP Configuration (for reading emails)
define('IMAP_HOST', 'imap.gmail.com');
define('IMAP_PORT', 993);
define('IMAP_ENCRYPTION', 'ssl');
define('IMAP_USERNAME', 'your-email@gmail.com');
define('IMAP_PASSWORD', 'your-app-password');

// SMTP Configuration (for sending emails)
define('SMTP_HOST', 'smtp.gmail.com');
define('SMTP_PORT', 587);
define('SMTP_ENCRYPTION', 'tls');
define('SMTP_USERNAME', 'your-email@gmail.com');
define('SMTP_PASSWORD', 'your-app-password');

Note: For Gmail, you need to use App Passwords instead of your regular password.

AI Provider Configuration

Option 1: Google Gemini (Free Tier Available)

define('AI_PROVIDER', 'gemini');
define('AI_API_KEY', 'your-gemini-api-key');
define('AI_MODEL', 'gemini-2.5-flash'); // Free tier model

Option 2: OpenAI

define('AI_PROVIDER', 'openai');
define('AI_API_KEY', 'sk-your-openai-key');
define('AI_MODEL', 'gpt-4o-mini');
define('AI_BASE_URL', 'https://api.openai.com/v1');

Option 3: Anthropic Claude

define('AI_PROVIDER', 'anthropic');
define('AI_API_KEY', 'sk-ant-your-key');
define('AI_MODEL', 'claude-3-5-sonnet-20241022');

Option 4: DeepSeek

define('AI_PROVIDER', 'deepseek');
define('AI_API_KEY', 'your-deepseek-key');
define('AI_MODEL', 'deepseek-chat');
define('AI_BASE_URL', 'https://api.deepseek.com');

Option 5: xAI Grok

define('AI_PROVIDER', 'grok');
define('AI_API_KEY', 'your-xai-key');
define('AI_MODEL', 'grok-4');
define('AI_BASE_URL', 'https://api.x.ai/v1');

πŸ’‘ Usage Examples

Load Emails

Load emails from your IMAP server with background processing and real-time progress tracking.

![Load Emails Interface](assets/images/Load Emails - EmailMasterAI - AI-Powered Email Assistant.png)

Load emails from your IMAP server with real-time progress tracking

Analyze Emails

Use natural language to analyze your emails:

  • "Summarize all emails from last week"
  • "Which emails require immediate action?"
  • "Translate important emails to Gujarati"
  • "List all meeting requests from the last 5 days"

Generate Replies

Create professional replies with simple instructions:

  • "Reply politely that I will check and get back soon"
  • "Thank them for the email and ask for more details"
  • "Accept the meeting request"

![Reply Email Interface](assets/images/Replay Email - EmailMasterAI - AI-Powered Email Assistant.png)

Generate professional email replies using AI with simple natural language instructions

Compose New Emails

Generate emails from scratch:

  • "Write a professional email to request a meeting next week"
  • "Send a thank you email for the interview"
  • "Ask for product pricing information"

![Send Email Interface](assets/images/Send Email - EmailMasterAI - AI-Powered Email Assistant.png)

Compose and send new emails with AI-generated content

πŸ—οΈ Project Structure

emailMasterAI/
β”œβ”€β”€ api/                    # API endpoints
β”‚   β”œβ”€β”€ analyze_emails.php
β”‚   β”œβ”€β”€ generate_email.php
β”‚   β”œβ”€β”€ generate_reply.php
β”‚   β”œβ”€β”€ load_emails.php
β”‚   └── send_email.php
β”œβ”€β”€ includes/              # Core PHP classes
β”‚   β”œβ”€β”€ AIService.php      # AI API integration
β”‚   β”œβ”€β”€ EmailReader.php    # IMAP email reading
β”‚   β”œβ”€β”€ EmailSender.php    # SMTP email sending
β”‚   └── MimeDecoder.php    # MIME header decoding
β”œβ”€β”€ assets/                # Frontend assets
β”‚   β”œβ”€β”€ css/style.css
β”‚   β”œβ”€β”€ js/app.js
β”‚   └── images/            # Screenshots and images
β”œβ”€β”€ config.php.example     # Configuration template (copy to config.php)
β”œβ”€β”€ config.php             # Your configuration (create from example, NOT in repo)
β”œβ”€β”€ index.html             # Main UI
└── README.md

πŸ”§ API Endpoints

Email Operations

  • POST /api/load_emails.php - Load emails from IMAP
  • GET /api/get_saved_emails.php - List saved emails
  • POST /api/get_saved_email.php - Get single email

AI Operations

  • POST /api/analyze_emails.php - Analyze emails with AI
  • POST /api/generate_reply.php - Generate email reply
  • POST /api/generate_email.php - Generate new email

Email Sending

  • POST /api/send_reply.php - Send email reply
  • POST /api/send_email.php - Send new email

βœ… Testing & Verification

After installation, verify your setup using the built-in test script:

Access the test page:

http://your-domain/emailMasterAI/test_setup.php

The test script checks:

  • βœ… PHP version and extensions
  • βœ… IMAP connection
  • βœ… AI API connection
  • βœ… Database connection (if enabled)
  • βœ… File permissions
  • βœ… Configuration values

![Setup Verification](assets/images/Test-setup EmailMasterAI - Setup Verification.png)

Setup verification page showing all system checks and connection status

πŸ”’ Security

  • Never commit config.php - Contains sensitive credentials (automatically excluded via .gitignore)
  • Use config.php.example - This template file IS in the repo and shows all configuration options
  • Create config.php locally - Copy from example: cp config.php.example config.php
  • Use App Passwords - For Gmail and other providers (never use regular passwords)
  • Environment Variables - Consider using .env files in production
  • Input Sanitization - All user inputs are sanitized
  • HTTPS Recommended - Use HTTPS in production
  • Protect emails/ directory - Contains personal email data (excluded from Git)

πŸ“š Documentation

🀝 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

πŸ“ License

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

πŸ™ Acknowledgments

  • Built with PHP 8.3+
  • Uses IMAP and SMTP for email operations
  • Integrates with multiple AI providers
  • Inspired by the need for intelligent email management

πŸ”— Related Projects

πŸ“Š Keywords

Email management, AI email assistant, automated email replies, email analysis, AI-powered email, email automation, smart email, email AI, GPT email, Gemini email, Claude email, email productivity, IMAP automation, SMTP automation, email workflow, AI email tool, email management system, intelligent email, email assistant, automated email responses

⭐ Star History

If you find this project useful, please consider giving it a star on GitHub!


Made with ❀️ for better email management

For issues, questions, or contributions, please open an issue on GitHub.

About

AI-powered email management system with support for OpenAI, Gemini, Claude, DeepSeek, and Grok. Automate email analysis, reply generation, and composition.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages