MCP Mail Server
A Model Context Protocol server that enables email operations through POP3 and SMTP protocols in Cursor AI, allowing users to send, receive, list, and manage emails using natural language commands.
README
MCP Mail Server
Language: English | 中文
A Model Context Protocol (MCP) server that enables email operations through IMAP and SMTP protocols in Cursor AI. Features secure environment-based configuration for seamless email management.
✨ Features
📥 IMAP Features (Receive Emails)
- Connect to IMAP email servers with TLS support
- Open and manage multiple mailboxes (folders)
- Search messages using IMAP search criteria
- Retrieve messages by UID with full content
- Mark messages as seen/unseen
- Delete messages from server
- Get message counts and mailbox information
- List all available mailboxes
- Get unseen and recent messages
- Secure connection management
📤 SMTP Features (Send Emails)
- Connect to SMTP email servers
- Send emails (text and HTML formats)
- Support for CC and BCC recipients
- SSL/TLS encryption support
- Comprehensive error handling
📦 Installation
Method 1: Install via npm
npm install -g mcp-mail-server
Method 2: Use with npx (Recommended)
No installation required:
npx mcp-mail-server
⚙️ Cursor Configuration
Add the following configuration to your Cursor MCP settings:
Using npx (Recommended):
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": ["mcp-mail-server"],
"env": {
"IMAP_HOST": "your-imap-server.com",
"IMAP_PORT": "993",
"IMAP_SECURE": "true",
"SMTP_HOST": "your-smtp-server.com",
"SMTP_PORT": "465",
"SMTP_SECURE": "true",
"EMAIL_USER": "your-email@domain.com",
"EMAIL_PASS": "your-password"
}
}
}
}
Using global installation:
{
"mcpServers": {
"mcp-mail-server": {
"command": "mcp-mail-server",
"env": {
"IMAP_HOST": "your-imap-server.com",
"IMAP_PORT": "993",
"IMAP_SECURE": "true",
"SMTP_HOST": "your-smtp-server.com",
"SMTP_PORT": "465",
"SMTP_SECURE": "true",
"EMAIL_USER": "your-email@domain.com",
"EMAIL_PASS": "your-password"
}
}
}
}
🛠️ Available Tools
connect_imap
Connect to IMAP email server using preconfigured settings.
open_mailbox
Open a specific mailbox (folder) for operations.
Parameters:
mailboxName(string, optional): Name of the mailbox to open (default: "INBOX")readOnly(boolean, optional): Open mailbox in read-only mode (default: false)
list_mailboxes
List all available mailboxes (folders) on the server.
search_messages
Search messages using IMAP search criteria.
Parameters:
criteria(array, optional): IMAP search criteria (default: ["ALL"])- Examples:
["UNSEEN"],["SINCE", "2024-01-01"],["FROM", "sender@example.com"]
- Examples:
get_messages
Retrieve multiple messages by their UIDs.
Parameters:
uids(array): Array of message UIDs to retrievemarkSeen(boolean, optional): Mark messages as seen when retrieving (default: false)
get_message
Retrieve complete content of a specific email by UID.
Parameters:
uid(number): Message UID to retrievemarkSeen(boolean, optional): Mark message as seen when retrieving (default: false)
delete_message
Delete a specific email message by UID.
Parameters:
uid(number): Message UID to delete
get_message_count
Get the total number of messages in current mailbox.
get_unseen_messages
Get all unseen (unread) messages in current mailbox.
get_recent_messages
Get all recent messages in current mailbox.
disconnect_imap
Disconnect from the IMAP server.
connect_smtp
Connect to SMTP email server using preconfigured settings.
send_email
Send an email via SMTP.
Parameters:
to(string): Recipient email address(es), comma-separatedsubject(string): Email subjecttext(string, optional): Plain text email bodyhtml(string, optional): HTML email bodycc(string, optional): CC recipients, comma-separatedbcc(string, optional): BCC recipients, comma-separated
disconnect_smtp
Disconnect from the SMTP server.
quick_connect
Connect to both IMAP and SMTP servers simultaneously using preconfigured settings.
💡 Usage Examples
Note: This project uses preconfigured email server settings via environment variables.
In Cursor, you can use natural language commands:
🚀 Quick Start
- Connect to all email servers at once:
Connect to email servers
or
Quick connect to mail
📥 Receiving Emails
- Connect to IMAP server (if not using quick connect):
Connect to IMAP server
- Open a mailbox:
Open INBOX mailbox
or
Open Sent mailbox in read-only mode
- Search for emails:
Search for unseen messages
or
Search for messages from sender@example.com since 2024-01-01
- Get specific email by UID:
Show me the content of email with UID 123
- Get all unseen messages:
Show me all unread emails
- List available mailboxes:
Show me all email folders
- Delete email by UID:
Delete email with UID 123
📤 Sending Emails
- Connect to SMTP server (if not using quick connect):
Connect to SMTP server
- Send simple email:
Send email to recipient@example.com with subject "Test Email" and message "Hello, this is a test email"
- Send HTML email:
Send HTML email to recipient@example.com with subject "Welcome" and HTML content "<h1>Welcome!</h1><p>This is an HTML email</p>"
🔧 Environment Configuration
Required Environment Variables
⚠️ All environment variables are required - no defaults provided!
| Variable | Description | Example Value |
|---|---|---|
IMAP_HOST |
IMAP server address | your-imap-server.com |
IMAP_PORT |
IMAP port number | 993 |
IMAP_SECURE |
Enable TLS (true/false) | true |
SMTP_HOST |
SMTP server address | your-smtp-server.com |
SMTP_PORT |
SMTP port number | 465 |
SMTP_SECURE |
Enable SSL (true/false) | true |
EMAIL_USER |
Email username | your-email@domain.com |
EMAIL_PASS |
Email password | your-password |
Configuration Validation
- Server will fail to start if any required environment variable is missing
- Boolean values must be
trueorfalse(case-insensitive) - Port numbers must be valid integers
- Configuration summary is displayed on startup (passwords are hidden)
⚠️ Security Considerations
- Use app-specific passwords when available (Gmail, Outlook, etc.)
- Ensure secure network connections in production
- Environment variables are the recommended configuration method
- TLS/SSL encryption is strongly recommended for both protocols
🔨 Development
To modify or develop this project:
- Clone the repository:
git clone https://github.com/yunfeizhu/mcp-mail-server.git
cd mcp-mail-server
- Install dependencies:
npm install
- Build the project:
npm run build
- Local testing:
# Set environment variables
export IMAP_HOST=your-imap-server.com
export IMAP_PORT=993
export IMAP_SECURE=true
export SMTP_HOST=your-smtp-server.com
export SMTP_PORT=465
export SMTP_SECURE=true
export EMAIL_USER=your-email@domain.com
export EMAIL_PASS=your-password
# Run the server
npm start
📊 Package Information
- Package Name:
mcp-mail-server - Executable:
mcp-mail-server - Node.js Version: >=18.0.0
- License: MIT
- Repository: GitHub
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。