A full-stack AI-powered email management system that fetches real emails, provides smart summaries, generates quick replies, and includes an intelligent chat agent.
- โ Real Email Access: Fetches live emails from your inbox via IMAP
- โ Send Real Emails: Send emails via SMTP
- โ AI-Powered Analysis: Summarizes inbox, detects urgent emails, identifies pending replies
- โ Smart Quick Replies: One-click reply generation (Acknowledge, Ask Update, Confirm, Decline)
- โ Chat Agent: Interactive AI assistant that can draft emails, check inbox, and answer questions
- โ LLM Function Tool Calling: Uses Local LLM exposed via FastAPI with function calling for intelligent email management
College-Email-Project/
โโโ backend/
โ โโโ src/
โ โ โโโ services/
โ โ โ โโโ imapService.ts # IMAP email fetching
โ โ โ โโโ emailService.ts # SMTP email sending
โ โ โ โโโ agentService.ts # agent with tool calling
โ โ โโโ routes/
โ โ โ โโโ inbox.ts # /api/inbox endpoints
โ โ โ โโโ email.ts # /api/email/send endpoint
โ โ โ โโโ agent.ts # /api/agent/chat endpoint
โ โ โโโ index.ts # Express server
โ โโโ .env # Your email credentials (create this)
โ โโโ .env.example # Template for .env
โ โโโ package.json
โโโ frontend/
โ โโโ src/
โ โ โโโ pages/
โ โ โ โโโ Inbox.tsx # Inbox Analyzer page
โ โ โ โโโ Chat.tsx # Chat Agent page
โ โ โโโ services/
โ โ โ โโโ api.ts # API client
โ โ โโโ App.tsx
โ โ โโโ main.tsx
โ โโโ package.json
โโโ README.md
- Node.js 18+ installed
- An email account (Gmail recommended)
- OpenAI API key
-
Enable 2-Factor Authentication on your Google account
-
Generate App Password:
- Go to Google Account Settings
- Security โ 2-Step Verification โ App passwords
- Generate a new app password for "Mail"
- Copy the 16-character password
-
Your Gmail credentials:
IMAP_HOST=imap.gmail.comIMAP_PORT=993SMTP_HOST=smtp.gmail.comSMTP_PORT=587IMAP_USER=your-email@gmail.comSMTP_USER=your-email@gmail.comIMAP_PASS=your-16-char-app-passwordSMTP_PASS=your-16-char-app-password
Outlook/Hotmail:
- IMAP:
outlook.office365.com:993 - SMTP:
smtp.office365.com:587
Yahoo:
- IMAP:
imap.mail.yahoo.com:993 - SMTP:
smtp.mail.yahoo.com:587
Custom IMAP/SMTP:
- Check your email provider's documentation for IMAP/SMTP settings
- Go to OpenAI Platform
- Sign up or log in
- Navigate to API Keys section
- Create a new API key
- Copy the key (starts with
sk-...)
-
Navigate to backend directory:
cd backend -
Install dependencies:
npm install
-
Create
.envfile:cp .env.example .env
-
Edit
.envand fill in your credentials:# IMAP Configuration IMAP_HOST=imap.gmail.com IMAP_PORT=993 IMAP_USER=your-email@gmail.com IMAP_PASS=your-app-password-here # SMTP Configuration SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USER=your-email@gmail.com SMTP_PASS=your-app-password-here # OpenAI API Key OPENAI_API_KEY=sk-your-openai-api-key-here # Server Port (optional) PORT=8000
-
Navigate to frontend directory:
cd ../frontend -
Install dependencies:
npm install
Terminal 1 - Backend:
cd backend
npm run devBackend will run on http://localhost:8000
Terminal 2 - Frontend:
cd frontend
npm run devFrontend will run on http://localhost:5173 and auto-open in browser
You can also create a root package.json to run both:
# In project root
npm run dev:backend # Runs backend
npm run dev:frontend # Runs frontend| Variable | Description | Example |
|---|---|---|
IMAP_HOST |
IMAP server hostname | imap.gmail.com |
IMAP_PORT |
IMAP server port (usually 993) | 993 |
IMAP_USER |
Your email address | your-email@gmail.com |
IMAP_PASS |
App password or email password | abcd efgh ijkl mnop |
SMTP_HOST |
SMTP server hostname | smtp.gmail.com |
SMTP_PORT |
SMTP server port (587 or 465) | 587 |
SMTP_USER |
Your email address | your-email@gmail.com |
SMTP_PASS |
App password or email password | abcd efgh ijkl mnop |
OPENAI_API_KEY |
OpenAI API key | sk-... |
| Variable | Description | Default |
|---|---|---|
PORT |
Backend server port | 8000 |
- View Inbox: Automatically loads and displays your real emails
- AI Summary: See AI-generated summary of your inbox
- Categories: Emails are categorized into:
- ๐ด Urgent: Needs immediate attention
- โณ Pending Replies: Emails requiring your response
- โน๏ธ Informational: General emails
- Quick Replies: Click any of the quick reply buttons:
- Acknowledge: Brief acknowledgment
- Ask Update: Request for update
- Confirm: Confirmation email
- Decline: Polite decline
- Send Emails: Review AI-generated draft, edit if needed, and send
Ask the AI assistant questions like:
- "What is urgent today?"
- "Draft a short email to professor about project submission"
- "Who hasn't replied yet?"
- "Summarize last 10 emails"
- "Show me unread emails"
The agent uses tool calling to:
- Fetch your real inbox
- Send emails on your behalf
- Extract contacts
- Analyze email patterns
Fetches inbox emails
- Query params:
?limit=50(optional) - Returns:
{ emails: Email[], count: number }
Sends an email
- Body:
{ to: string, subject: string, body: string, html?: string } - Returns:
{ success: true, message: string }
Chat with AI agent
- Body:
{ message: string, history?: ChatMessage[] } - Returns:
{ reply: string, toolExecuted?: object, history: ChatMessage[] }
-
Error: "Authentication failed"
- Verify your email and password are correct
- For Gmail, ensure you're using an App Password, not your regular password
- Check if 2FA is enabled (required for App Passwords)
-
Error: "Connection timeout"
- Check your internet connection
- Verify IMAP_HOST and IMAP_PORT are correct
- Some networks block IMAP ports; try a different network
-
Error: "Invalid login"
- Use App Password for Gmail
- Verify SMTP_USER and SMTP_PASS match
- Check SMTP_PORT (587 for TLS, 465 for SSL)
-
Error: "Message rejected"
- Some providers have sending limits
- Check spam folder settings
- Verify recipient email is valid
- Error: "Invalid API key"
- Verify your API key starts with
sk- - Check if you have credits in your OpenAI account
- Ensure the key has not been revoked
- Verify your API key starts with
- Error: "Network Error" or CORS issues
- Ensure backend is running on port 8000
- Check browser console for errors
- Verify
API_BASE_URLinfrontend/src/services/api.tsmatches your backend URL
- Email Limits: Some providers limit IMAP connections. If you see connection errors, wait a few minutes and try again.
- Rate Limiting: If you are using OpenAI API, it has rate limits. If you hit limits, wait before making more requests. If you are using local LLM you are set.
Happy Email Managing! ๐งโจ