Enables sending and receiving emails through Gmail using SMTP and IMAP/POP3 protocols, with support for attachments, HTML content, and filtering unread messages.
Email Send/Receive MCP Server
A Model Context Protocol (MCP) server for sending and receiving emails via SMTP, POP3, and IMAP. Built with FastMCP 2.0 and optimized for deployment on Azure Container Apps.
Features
Email Sending (SMTP)
Send emails with validated recipient addresses
Support for CC and BCC
HTML and plain text email bodies
File attachments support
Configurable sender information
Email Receiving (IMAP/POP3)
Retrieve emails from IMAP servers
Support for POP3 protocol
Filter by mailbox/folder
Unread emails filtering
Attachment information extraction
Email Validation
RFC-compliant email address validation
Automatic email normalization
Batch validation for multiple recipients
Installation
Using uv (recommended)
Using pip
Configuration
Copy the example environment file:
Edit
.envwith your email server credentials:
Gmail Setup
For Gmail, you'll need to:
Enable 2-factor authentication
Generate an App Password: https://myaccount.google.com/apppasswords
Use the App Password in the configuration
Usage
Running the MCP Server
The server will start and expose the following MCP tools:
Available Tools
send_email
Send an email via SMTP.
Parameters:
recipient(required): Email address of the recipientsubject(required): Email subject/titlebody(required): Email body contentattachments(optional): List of file paths to attachcc(optional): List of CC recipientsbcc(optional): List of BCC recipientsis_html(optional): Whether the body is HTML (default: False)
Example:
receive_emails_imap
Receive emails using IMAP protocol.
Parameters:
mailbox(optional): Mailbox to read from (default: "INBOX")limit(optional): Maximum number of emails to retrieve (default: 10)unread_only(optional): Only retrieve unread emails (default: False)
Example:
receive_emails_pop3
Receive emails using POP3 protocol.
Parameters:
limit(optional): Maximum number of emails to retrieve (default: 10)
Example:
Docker Deployment
Build the Docker image
Run the container
Or use a .env file:
Azure Container Apps Deployment
Create an Azure Container Registry (ACR)
Push the Docker image to ACR
Create a Container App with environment variables
Configure scaling and networking as needed
Example Azure CLI commands:
Development
Running Tests
Code Formatting
Type Checking
Architecture
Technology Stack
FastMCP 2.0: MCP server framework
aiosmtplib: Async SMTP client
aioimaplib: Async IMAP client
email-validator: RFC-compliant email validation
Pydantic: Settings management and validation
uv: Fast Python package manager
Security Considerations
Never commit
.envfiles with real credentialsUse App Passwords for Gmail and other providers
Store secrets securely in production (Azure Key Vault, etc.)
Validate all email addresses before sending
Implement rate limiting for production use
Use TLS/SSL for all email connections
Troubleshooting
Gmail "Less secure app" error
Enable 2FA and use App Passwords instead of your regular password
Connection timeout
Check firewall settings
Verify server addresses and ports
Ensure TLS/SSL settings match your provider
Authentication failed
Verify credentials in
.envCheck if App Password is used (for Gmail)
Ensure IMAP/POP3 access is enabled in email settings
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Support
For issues and questions, please open a GitHub issue.
This server cannot be installed
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.
Enables sending and receiving emails through SMTP, IMAP, and POP3 protocols with support for attachments, HTML content, and email validation.