Enables sending emails through Gmail's SMTP server, including support for HTML emails, attachments, bulk sending, and template-based emails with variable substitution.
Enables sending emails through Mailgun's SMTP service, including support for HTML emails, attachments, bulk sending, and template-based emails with variable substitution.
Enables sending emails through SendGrid's SMTP service, including support for HTML emails, attachments, bulk sending, and template-based emails with variable substitution.
MCP Sendmail Server
A Model Context Protocol (MCP) server with Streamable HTTP transport for sending emails via SMTP.
Features
✅ MCP Streamable HTTP - Full MCP specification compliance (2024-11-05)
✅ Stateful Sessions - Session management with automatic cleanup
✅ Bidirectional Communication - SSE for server-to-client messaging
✅ Stream Resumability - Reconnect and resume from last event
✅ Email Tools - Send emails, bulk emails, and template-based emails
✅ SMTP Support - Full SMTP/TLS support with authentication
✅ Attachments - Support for email attachments (base64 encoded)
✅ Docker Ready - Multi-stage build, production-optimized
✅ Type Safe - Full Python type hints and Pydantic models
✅ Async Support - FastAPI async/await patterns
✅ Backward Compatible - Legacy JSON-RPC 2.0 endpoints still work
Configuration
SMTP credentials are configured via environment variables. The repository includes .env.sh for easy configuration:
Quick Start
Option 1: Local Development
Option 2: Docker
Option 3: Docker Compose (Recommended)
Quick Start with Convenience Scripts
Manual Start
Configure your SMTP credentials using .env.sh:
Important: Always run source .env.sh before docker compose up to load the SMTP configuration, or use the ./start.sh script which does this automatically.
How it works: The docker-compose.yml reads environment variables from your shell using ${SMTP_HOST} syntax. If variables aren't set, it falls back to safe defaults (localhost:587).
Environment Variables
Variable | Description | Default |
| SMTP server hostname |
|
| SMTP server port |
|
| SMTP username/email | `` |
| SMTP password | `` |
Testing the Server
MCP Streamable HTTP (Recommended)
Available MCP Tools
1. send_email
Send an email with optional attachments, CC, and BCC.
Parameters:
to(string, required): Recipient email addresssubject(string, required): Email subjectbody(string, required): Email body contentfrom_addr(string, optional): Sender email address (defaults to SMTP_USER)cc(array, optional): List of CC recipientsbcc(array, optional): List of BCC recipientshtml(boolean, optional): Whether body is HTML (default: false)attachments(array, optional): List of attachments with filename and base64 content
Example:
2. send_bulk_email
Send the same email to multiple recipients.
Parameters:
recipients(array, required): List of recipient email addressessubject(string, required): Email subjectbody(string, required): Email body contentfrom_addr(string, optional): Sender email address (defaults to SMTP_USER)html(boolean, optional): Whether body is HTML (default: false)
Example:
3. send_template_email
Send an email using a template with variable substitution.
Parameters:
to(string, required): Recipient email addresssubject(string, required): Email subjecttemplate(string, required): Email template with {variable} placeholdersvariables(object, required): Dictionary of variable names and valuesfrom_addr(string, optional): Sender email address (defaults to SMTP_USER)html(boolean, optional): Whether template is HTML (default: false)
Example:
4. verify_connection
Verify SMTP connection and credentials.
Parameters: None
Returns: Connection status, server details, and port information
API Endpoints
MCP Streamable HTTP (Primary)
Method | Endpoint | Description |
POST |
| MCP requests with session management |
GET |
| Open SSE stream for server notifications |
GET |
| Health check |
Required Headers:
Mcp-Session-Id: Session ID (after initialize)Mcp-Protocol-Version:2024-11-05Accept:application/json, text/event-stream
Legacy Endpoints (Backward Compatible)
Method | Endpoint | Description |
POST |
,
,
| Plain JSON-RPC 2.0 (no sessions) |
GET |
| Legacy SSE (deprecated) |
JSON-RPC Methods
Method | Description |
| Initialize MCP session (returns session ID) |
| Keep-alive ping |
| List available tools |
| Execute a tool |
Project Structure
SMTP Configuration Examples
Gmail
Outlook/Office 365
SendGrid
Mailgun
Amazon SES
Security Features
TLS Encryption: All SMTP connections use TLS by default
Secure Credentials: SMTP credentials stored in environment variables
Input Validation: Email addresses and content validated
Non-root User: Docker runs as
mcpuser(UID 1000)
Development
Docker Image Details
Base Image:
python:3.11-slimSize: ~150-200MB (optimized with multi-stage build)
User: Non-root
mcpuserHealth Checks: Built-in
Volumes:
/app/logs(logs)
Troubleshooting
Gmail Authentication Issues
If you're using Gmail, you need to:
Enable 2-factor authentication
Generate an App Password (not your regular password)
Use the App Password in
SMTP_PASSWORD
Connection Timeouts
If you get connection timeouts:
Check your firewall settings
Verify the SMTP host and port
Try port 465 (SSL) instead of 587 (TLS)
Use the
verify_connectiontool to test
Certificate Errors
If you get SSL certificate errors:
Make sure you're using a valid SMTP server
Check if your network has SSL inspection enabled
Verify the server's certificate is valid
License
MIT License
Contributing
Fork the repository
Create a feature branch
Commit your changes
Push to the branch
Create a Pull Request
Support
For issues and questions, please open an issue on GitHub.
This server cannot be installed