imap-smtp-mcp
Enables reading, searching, sending, and managing emails via IMAP/SMTP for AOL Mail.
Enables reading, searching, sending, and managing emails via IMAP/SMTP for Apple Mail (iCloud).
Enables reading, searching, sending, and managing emails for self-hosted email servers using Dovecot.
Enables reading, searching, sending, and managing emails via IMAP/SMTP for Gmail.
Enables reading, searching, sending, and managing emails via IMAP/SMTP for iCloud Mail.
Enables reading, searching, sending, and managing emails via IMAP/SMTP for ProtonMail (via ProtonMail Bridge).
Enables reading, searching, sending, and managing emails via IMAP/SMTP for Zoho Mail.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
imap-smtp-mcp
Connect ANY mailbox to ANY AI agent. Expose Gmail, Outlook, Apple Mail (iCloud), Fastmail, ProtonMail, Yahoo, and every self-hosted server as Model Context Protocol tools, so any MCP-compatible agent (Claude Desktop, Hermes, your own scripts) can read, search, send, and manage email.
┌──────────────────┐ httpStream + SSE ┌──────────────────┐ IMAP ┌────────────┐
│ MCP client │ ──────────────────►│ imap-smtp-mcp │ ───────►│ Mail │
│ (Claude, │ │ (this server) │ │ server │
│ Hermes, etc.) │ │ │ SMTP │ (any) │
└──────────────────┘ └──────────────────┘ ───────►└────────────┘✨ Features
8 MCP tools:
server_info,list_mailboxes,list_emails,read_email,search_emails,send_email,mark_read,delete_email.Universal: works with any IMAP/SMTP server (Gmail, Outlook, Fastmail, ProtonMail, Dovecot, Stalwart, Postfix, etc.).
Transport: FastMCP 3.x with
httpStream(per-session, server-sent events) andstdio(for desktop integration).Production-ready: graceful shutdown, persistent connections, structured logging, error handling.
No secrets in code: configuration via environment variables only.
Related MCP server: anymail-mcp
📦 Installation
Prerequisites
Node.js ≥ 18
An IMAP/SMTP-enabled mailbox
For Gmail/Yahoo/Microsoft: an app password (not your account password). See provider-specific notes below.
From npm (once published)
npm install -g imap-smtp-mcp
imap-smtp-mcpFrom source
git clone https://github.com/YOUR_USERNAME/imap-smtp-mcp.git
cd imap-smtp-mcp
npm install
npm run build
npm startDevelopment mode (with hot reload)
npm run dev⚙️ Configuration
All configuration is via environment variables. Create a .env file or
export them in your shell / systemd unit.
Required
Variable | Description |
| IMAP server hostname (e.g. |
| IMAP username (often your full email address) |
| IMAP password or app password |
| SMTP server hostname (often same as IMAP host) |
| SMTP username |
| SMTP password or app password |
Optional
Variable | Default | Description |
|
| IMAP port (993 for SSL, 143 for STARTTLS) |
|
| Use TLS (set |
|
| Reject invalid TLS certs (set |
|
| SMTP port (465 for SSL, 587 for STARTTLS) |
|
| Use TLS |
|
| Reject invalid TLS certs |
|
| "From" address (if different from SMTP_USER) |
|
|
|
|
| HTTP port (only for httpStream) |
|
| Bind address (use |
|
|
|
|
| Directory for log files |
Example .env
IMAP_HOST=imap.gmail.com
IMAP_USER=you@gmail.com
IMAP_PASS=abcd efgh ijkl mnop
IMAP_PORT=993
IMAP_SECURE=true
IMAP_REJECT_UNAUTHORIZED=true
SMTP_HOST=smtp.gmail.com
SMTP_USER=you@gmail.com
SMTP_PASS=abcd efgh ijkl mnop
SMTP_PORT=465
SMTP_SECURE=true
FASTMCP_TRANSPORT=httpStream
FASTMCP_PORT=3143
FASTMCP_HOST=0.0.0.0
LOG_LEVEL=info
LOG_DIR=/var/log/imap-smtp-mcp🚀 Usage
As a daemon (recommended)
Once configured, just run:
imap-smtp-mcp
# [INFO] HTTP Stream listening on http://0.0.0.0:3143/mcpWith systemd
# /etc/systemd/system/imap-smtp-mcp.service
[Unit]
Description=IMAP/SMTP MCP Server
After=network.target
[Service]
Type=simple
User=imap-smtp
EnvironmentFile=/etc/imap-smtp-mcp.env
ExecStart=/usr/bin/node /opt/imap-smtp-mcp/dist/index.js
Restart=always
RestartSec=10
StandardOutput=append:/var/log/imap-smtp-mcp/mcp.log
StandardError=append:/var/log/imap-smtp-mcp/mcp.err.log
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now imap-smtp-mcp
systemctl status imap-smtp-mcpWith Docker
FROM node:20-alpine
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY dist ./dist
ENV NODE_ENV=production
EXPOSE 3143
CMD ["node", "dist/index.js"]docker run -d --name imap-smtp-mcp \
-p 3143:3143 \
--env-file ./.env \
imap-smtp-mcp:latestAs an MCP client (Claude Code, etc.)
{
"mcpServers": {
"mail": {
"url": "http://localhost:3143/mcp"
}
}
}For a remote server, replace localhost with the host:
{
"mcpServers": {
"mail": {
"url": "http://localhost:3143/mcp"
}
}
}As stdio (alternative)
If you prefer stdio transport (one process per session, e.g. for local desktop):
{
"mcpServers": {
"mail": {
"command": "node",
"args": ["/path/to/imap-smtp-mcp/dist/index.js"],
"env": {
"FASTMCP_TRANSPORT": "stdio",
"IMAP_HOST": "imap.gmail.com",
"IMAP_USER": "you@gmail.com",
"IMAP_PASS": "..."
}
}
}
}🧰 Tools reference
server_info
Returns IMAP/SMTP server details and inbox counts.
{
"user": "you@example.com",
"imap": "imap.example.com:993",
"smtp": "smtp.example.com:465",
"inbox_total": 42,
"inbox_unread": 7
}list_mailboxes
Lists all mailboxes with message counts.
[
{ "name": "INBOX", "total": 42, "unread": 7 },
{ "name": "Sent", "total": 15, "unread": 0 },
{ "name": "Drafts", "total": 0, "unread": 0 }
]list_emails
Lists emails in a mailbox.
Param | Type | Default | Description |
| string |
| Mailbox name |
| number |
| Max results (1-500) |
| boolean |
| Only return unread emails |
[
{
"uid": 1234,
"subject": "Hello",
"from": "alice@example.com",
"to": "you@example.com",
"date": "2026-07-25T18:00:00.000Z",
"flags": ["\\Seen"],
"preview": "First 200 chars of body..."
}
]read_email
Reads a full email by UID.
Param | Type | Description |
| number | Email UID (from |
| string | Mailbox name (default |
Returns the email with full body. body is parsed as text/plain from the MIME source.
search_emails
Searches emails by keyword (matches body text).
Param | Type | Default | Description |
| string | (required) | Keyword |
| string |
| Mailbox |
| number |
| Max results |
send_email
Sends an email via SMTP.
Param | Type | Description |
| string | Recipient address |
| string | Subject line |
| string | Plain-text body |
Returns { status: "sent", to, subject, messageId }.
mark_read
Marks an email as read or unread.
Param | Type | Default | Description |
| number | (required) | Email UID |
| string |
| Mailbox |
| boolean |
|
|
delete_email
Marks an email as deleted and expunges it. Permanent.
Param | Type | Default | Description |
| number | (required) | Email UID |
| string |
| Mailbox |
📧 Provider notes
Gmail
Enable 2FA on your Google account
Create an app password
Use the app password as
IMAP_PASS/SMTP_PASS
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_SECURE=trueOutlook / Microsoft 365 / Hotmail / Live
Enable 2FA on your Microsoft account
Create an app password via Microsoft account security
IMAP_USERshould be your full email address
IMAP_HOST=outlook.office365.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.office365.com
SMTP_PORT=587
SMTP_SECURE=false # STARTTLS, not implicit TLSApple iCloud / Apple Mail / me.com / mac.com
Enable 2FA on your Apple Account
Generate an app-specific password at appleid.apple.com → Sign-In and Security → App-Specific Passwords
Use your full iCloud email and the app-specific password
IMAP_HOST=imap.mail.me.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.mail.me.com
SMTP_PORT=587
SMTP_SECURE=false # STARTTLSFastmail
IMAP_HOST=imap.fastmail.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.fastmail.com
SMTP_PORT=465
SMTP_SECURE=trueProtonMail Bridge
Run ProtonMail Bridge locally, then:
IMAP_HOST=127.0.0.1
IMAP_PORT=1143
IMAP_SECURE=false
SMTP_HOST=127.0.0.1
SMTP_PORT=1025
SMTP_SECURE=false
IMAP_USER=your-bridge-username
IMAP_PASS=your-bridge-passwordYahoo Mail / AOL
IMAP_HOST=imap.mail.yahoo.com
SMTP_HOST=smtp.mail.yahoo.comGenerate an app password in Yahoo Account Security.
Zoho Mail
IMAP_HOST=imap.zoho.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.zoho.com
SMTP_PORT=465
SMTP_SECURE=trueSelf-hosted (Dovecot, Stalwart, Postfix, Mailcow, etc.)
For self-hosted mail servers with self-signed certificates:
IMAP_REJECT_UNAUTHORIZED=false
SMTP_REJECT_UNAUTHORIZED=falseFor production with valid certificates (Let's Encrypt), set both to true.
🛠️ Development
Scripts
npm run build # Compile TypeScript to dist/
npm run dev # Watch mode with tsx
npm run lint # ESLint
npm test # Run unit tests (vitest)
npm run test:watch # Tests in watch mode
npm run format # PrettierProject layout
src/
index.ts # Entry point
config.ts # Env loading + Zod validation
logger.ts # Pino logger setup
mail-service.ts # IMAP/SMTP operations
tools.ts # MCP tool definitions
tests/
config.test.ts # Config validation tests
mail-service.test.ts # MailService with mocks
tools.test.ts # Tool registration + dispatch
.github/
workflows/
ci.yml # Lint + test + build on Node 18/20/22Adding a new tool
Add a method to
MailService(insrc/mail-service.ts).Register the tool in
registerMailTools(insrc/tools.ts).Add a test in
tests/tools.test.ts.
🔒 Security
No secrets in code. All credentials come from environment variables.
Use app passwords, not account passwords, for Gmail/Outlook/Yahoo.
For production, set
IMAP_REJECT_UNAUTHORIZED=trueandSMTP_REJECT_UNAUTHORIZED=truewith valid certificates.Bind
FASTMCP_HOST=127.0.0.1if the MCP client runs on the same host.For remote access, place behind a reverse proxy (nginx) with TLS.
📜 License
MIT — see LICENSE.
🤝 Contributing
Issues and pull requests welcome. Please run npm run lint && npm test before
submitting.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Your IMAP mailbox as an MCP server: read, search and (if you allow it) organize mail. Open source.
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
Real email inboxes for AI agents: register, receive, read and send mail over MCP. Free to receive.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA generic IMAP and SMTP MCP server that enables AI agents to interact with email accounts for reading, searching, and sending messages. It provides high-level tools for managing email workflows like daily digests and folder organization across any standard email provider.1MIT
- AlicenseNot gradedqualityDmaintenanceConnects any IMAP/SMTP mailbox to AI agents via MCP, enabling email read, search, send, reply, and management through natural language.13 npmMIT
- AlicenseNot gradedqualityDmaintenanceA self-hosted, multi-mailbox MCP server that exposes IMAP/SMTP operations as tools for AI agents, enabling email management like listing folders, reading, searching, sending, and moving messages via natural language.MIT
- FlicenseBqualityBmaintenanceEnables external AI agents to read, send, and manage email over IMAP/SMTP via MCP, including inbox listing, search, drafts, scheduled/batch sending, and operations like reply, archive, and labels.303-