Skip to main content
Glama

MCP Mail Server

by yunfeizhu

MCP Mail Server

NPM Version

Language: English | 中文

A Model Context Protocol server for IMAP/SMTP email operations with Claude, Cursor, and other AI assistants.

Features

  • IMAP Operations: Search, read, and manage emails across mailboxes
  • SMTP Support: Send emails with HTML/text content and attachments
  • Secure Configuration: Environment-based setup with TLS/SSL support
  • AI-Friendly: Natural language commands for email operations
  • Auto Connection Management: Automatic IMAP/SMTP connection handling
  • Multi-Mailbox Support: Access INBOX, Sent, and custom folders

Quick Start

  1. Install: npm install -g mcp-mail-server
  2. Configure environment variables (see Configuration)
  3. Add to your MCP client configuration
  4. Use natural language: "Show me unread emails from today"

Installation

Add to your claude_desktop_config.json:

{ "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" } } } }

Add to your Cursor MCP settings:

{ "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" } } } }

For global installation:

npm install -g mcp-mail-server

Then configure with:

{ "mcpServers": { "mcp-mail-server": { "command": "mcp-mail-server" } } }

Available Tools

ToolDescription
connect_allConnect to both IMAP and SMTP servers
get_connection_statusCheck connection status and server info
disconnect_allDisconnect from all servers
open_mailboxOpen specific mailbox/folder
list_mailboxesList available mail folders
search_messagesSearch emails with IMAP criteria
search_by_senderFind emails from specific sender
search_by_subjectSearch by subject keywords
search_by_bodySearch message content
search_since_dateFind emails since date
search_unreplied_from_senderFind unreplied emails from specific sender
search_larger_thanFind emails by size
get_messageRetrieve email by UID
get_messagesRetrieve multiple emails
delete_messageDelete email by UID
get_unseen_messagesGet all unread emails
get_recent_messagesGet recent emails
send_emailSend email via SMTP
reply_to_emailReply to specific email

Connection Management

  • connect_all: No parameters required
  • get_connection_status: No parameters required
  • disconnect_all: No parameters required

Mailbox Operations

  • open_mailbox: mailboxName (string, default: "INBOX"), readOnly (boolean)
  • list_mailboxes: No parameters required

Search Operations

  • search_messages: criteria (array, IMAP search criteria)
  • search_by_sender: sender (string, email address)
  • search_by_subject: subject (string, keywords)
  • search_by_body: text (string, search text)
  • search_since_date: date (string, date format)
  • search_unreplied_from_sender: sender (string, email address), startDate (string, optional), endDate (string, optional)
  • search_larger_than: size (number, bytes)

Message Operations

  • get_message: uid (number), markSeen (boolean, optional)
  • get_messages: uids (array), markSeen (boolean, optional)
  • delete_message: uid (number)

Email Sending

  • send_email: to (string), subject (string), text (string, optional), html (string, optional), cc (string, optional), bcc (string, optional)
  • reply_to_email: originalUid (number), text (string), html (string, optional), replyToAll (boolean, optional), includeOriginal (boolean, optional)

Usage Examples

Use natural language commands with your AI assistant:

Basic Operations

  • "Connect to my email servers"
  • "Show me all unread emails"
  • "Search for emails from boss@company.com"
  • "Send an email to team@company.com about the meeting"
  • "Reply to email with UID 123"

Advanced Searches

  • "Find emails with 'urgent' in the subject from last week"
  • "Show me unreplied emails from boss@company.com"
  • "Show me large emails over 5MB"
  • "Get all emails from the Sales folder"

Email Management

  • "Delete the email with UID 123"
  • "Mark recent emails as read"
  • "List all my email folders"

Configuration

Environment Variables

⚠️ All variables are required

VariableDescriptionExample
IMAP_HOSTIMAP server addressimap.gmail.com
IMAP_PORTIMAP port number993
IMAP_SECUREEnable TLStrue
SMTP_HOSTSMTP server addresssmtp.gmail.com
SMTP_PORTSMTP port number465
SMTP_SECUREEnable SSLtrue
EMAIL_USEREmail usernameyour-email@gmail.com
EMAIL_PASSEmail password/app passwordyour-app-password

Common Email Providers

IMAP_HOST=imap.gmail.com IMAP_PORT=993 IMAP_SECURE=true SMTP_HOST=smtp.gmail.com SMTP_PORT=465 SMTP_SECURE=true EMAIL_USER=your-email@gmail.com EMAIL_PASS=your-app-password

Note: Use App Passwords instead of your regular password.

IMAP_HOST=outlook.office365.com IMAP_PORT=993 IMAP_SECURE=true SMTP_HOST=smtp.office365.com SMTP_PORT=587 SMTP_SECURE=true EMAIL_USER=your-email@outlook.com EMAIL_PASS=your-password

Security Notes

  • Use App Passwords: Enable 2FA and use app-specific passwords when available
  • TLS/SSL Required: Always use secure connections (IMAP_SECURE=true, SMTP_SECURE=true)
  • Environment Variables: Never hardcode credentials in configuration files

Development

  1. Clone the repository:
    git clone https://github.com/yunfeizhu/mcp-mail-server.git cd mcp-mail-server
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build
  4. 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
  5. Run the server:
    npm start

Contributing

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

License

MIT License - see LICENSE file for details.


Package Information:

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

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.

  1. Features
    1. Quick Start
      1. Installation
        1. Available Tools
          1. Connection Management
          2. Mailbox Operations
          3. Search Operations
          4. Message Operations
          5. Email Sending
        2. Usage Examples
          1. Basic Operations
          2. Advanced Searches
          3. Email Management
        3. Configuration
          1. Environment Variables
          2. Common Email Providers
          3. Security Notes
        4. Development
          1. Contributing
            1. License

              Related MCP Servers

              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that enables AI assistants to explore and interact with Cursor IDE's SQLite databases, providing access to project data, chat history, and composer information.
                Last updated -
                21
                Python
                • Apple
              • A
                security
                F
                license
                A
                quality
                A Model Context Protocol server that enhances Claude in Cursor AI with advanced reasoning capabilities including Monte Carlo Tree Search, Beam Search, R1 Transformer, and Hybrid Reasoning methods.
                Last updated -
                8
                13
                TypeScript
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that enables Cursor AI assistants to interact with Todoist tasks directly from the coding environment, supporting advanced task filtering and rich formatting.
                Last updated -
                39
                Python
                • Linux
                • Apple
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that enables AI assistants to access and manage email through IMAP, supporting browsing, searching, reading, and organizing emails while learning user preferences over time.
                Last updated -
                16
                Python
                • Linux
                • Apple

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/yunfeizhu/mcp-mail-server'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server