Skip to main content
Glama

MCP Mail Server

by yunfeizhu

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

No installation required:

npx mcp-mail-server

⚙️ Cursor Configuration

Add the following configuration 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" } } } }
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"]
get_messages

Retrieve multiple messages by their UIDs.

Parameters:

  • uids (array): Array of message UIDs to retrieve
  • markSeen (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 retrieve
  • markSeen (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-separated
  • subject (string): Email subject
  • text (string, optional): Plain text email body
  • html (string, optional): HTML email body
  • cc (string, optional): CC recipients, comma-separated
  • bcc (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
  1. Connect to all email servers at once:
Connect to email servers

or

Quick connect to mail
📥 Receiving Emails
  1. Connect to IMAP server (if not using quick connect):
Connect to IMAP server
  1. Open a mailbox:
Open INBOX mailbox

or

Open Sent mailbox in read-only mode
  1. Search for emails:
Search for unseen messages

or

Search for messages from sender@example.com since 2024-01-01
  1. Get specific email by UID:
Show me the content of email with UID 123
  1. Get all unseen messages:
Show me all unread emails
  1. List available mailboxes:
Show me all email folders
  1. Delete email by UID:
Delete email with UID 123
📤 Sending Emails
  1. Connect to SMTP server (if not using quick connect):
Connect to SMTP server
  1. Send simple email:
Send email to recipient@example.com with subject "Test Email" and message "Hello, this is a test email"
  1. 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!

VariableDescriptionExample Value
IMAP_HOSTIMAP server addressyour-imap-server.com
IMAP_PORTIMAP port number993
IMAP_SECUREEnable TLS (true/false)true
SMTP_HOSTSMTP server addressyour-smtp-server.com
SMTP_PORTSMTP port number465
SMTP_SECUREEnable SSL (true/false)true
EMAIL_USEREmail usernameyour-email@domain.com
EMAIL_PASSEmail passwordyour-password
Configuration Validation
  • Server will fail to start if any required environment variable is missing
  • Boolean values must be true or false (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:

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

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 -
    38
    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 -
    15
    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