How to send and receive emails using Email Send/Receive MCP Server

This guide demonstrates how to set up and use the Email Send/Receive MCP Server to send and receive emails through the Model Context Protocol (MCP). You'll learn how to clone and install the server, configure your email account credentials, and use the MCP Inspector to execute email automation commands.

What is Email Send/Receive MCP Server?

Email Send/Receive MCP Server is a locally hosted Model Context Protocol server that provides programmatic access to email accounts via standard IMAP and SMTP protocols. It allows developers and AI assistants to send emails, list inbox messages, and retrieve full email content through standardized MCP commands, enabling automated email workflows and AI-driven email management. Unlike cloud-based email integrations, this server runs on your own machine and works with any IMAP/SMTP compatible email provider.

Steps to follow

  1. Clone the repository and install dependencies
  2. Configure .env file
  3. Switch transport to stdio
  4. Fix email validation and SSL certificate errors (optional)
  5. Run MCP Inspector with the email server
  6. Connect to the email MCP server and list tools
  7. Send an email
  8. Receive an email

Quick reference commands

# Clone and install
git clone https://github.com/bedro96/email-send-mcp.git
cd email-send-mcp
pip install -e .

# Switch transport to stdio in main.py
server.run(transport="http", host="0.0.0.0", port=8888, path="/mcp")  -->  server.run(transport="stdio")

# Run MCP Inspector with the email server
npx @modelcontextprotocol/inspector python main.py

Read more about the MCP inspector at: Model Context Protocol (MCP) Inspector

How to set up the Email Send/Receive MCP Server

The following video shows how to clone, install, and configure the Email Send/Receive MCP Server step-by-step. The video covers creating a project folder, cloning the repository, installing Python dependencies, editing the environment configuration file, and switching the server transport to stdio.

Step 1 - Clone the repository and install dependencies

Create a new folder on your system where the MCP server files will be stored. Keeping the server in a dedicated folder makes it easier to manage and update later (Figure 1).

Create a folder for the MCP server
Figure 1 - Create a folder for the MCP server

Open a terminal window inside the newly created folder. You can do this by right-clicking the folder and selecting "Open in Terminal" (Figure 2).

Open the folder in terminal
Figure 2 - Open the folder in terminal

Run the git clone command below to download the repository from GitHub into your folder (Figure 3).

You need Git installed on your system to run this command. If you don't have Git installed, download it from git-scm.com before proceeding.

git clone https://github.com/bedro96/email-send-mcp.git

Run the git clone command
Figure 3 - Clone the repository

Once the clone is complete, navigate into the cloned repository folder using the cd command (Figure 4).

cd email-send-mcp

Navigate into the cloned folder
Figure 4 - Navigate into the cloned folder

Install the required Python dependencies by running the command below. The -e flag installs the package in editable mode, which is required if you need to apply source code modifications (Figure 5).

You need Python and pip installed on your system to run this command. If you don't have Python installed, check our our How to install Python on Windows guide, or download it from python.org before proceeding.

pip install -e .

Install dependencies using pip
Figure 5 - Install dependencies using pip

Wait for pip to finish downloading and installing all packages. Once the installation completes successfully, you can close this terminal window (Figure 6).

Wait for install to finish then close the terminal
Figure 6 - Wait for installation to complete

Step 2 - Configure .env file

Open the .env file located in the cloned repository folder using a text editor. This file contains all the connection settings the server needs to communicate with your email provider (Figure 7).

Open .env file in email send MCP folder
Figure 7 - Open the .env configuration file

Fill in your email account details in the .env file. Replace the placeholder values with your actual SMTP and IMAP host addresses, port numbers, login credentials, and SSL settings (Figure 8).

# Email Server Configuration (SMTP)
SMTP_SERVER=your-smtp-server
SMTP_PORT=port
SMTP_USERNAME=your@email.com
SMTP_PASSWORD=your-smtp-password
SMTP_USE_TLS=false

# Email Server Configuration (IMAP)
IMAP_SERVER=your-imap-server
IMAP_PORT=port
IMAP_USERNAME=your@email.com
IMAP_PASSWORD=your-imap-password
IMAP_USE_SSL=false

# Email Settings
DEFAULT_FROM_EMAIL=your@email.com
DEFAULT_FROM_NAME=MCP Email Server
MAX_ATTACHMENT_SIZE_MB=25

Modify the .env file
Figure 8 - Enter your email credentials in the .env file

Save the file and close the text editor once all values have been filled in correctly (Figure 9).

Save file and close text editor
Figure 9 - Save the .env file

Step 3 - Switch transport to stdio

The server is configured by default to run as an HTTP server. To use it with the MCP Inspector, the transport must be changed to stdio. Locate and open main.py in the repository folder using a text editor (Figure 10).

Locate and open main.py file
Figure 10 - Locate and open main.py

Find the server.run() call and replace it with the stdio version shown below. This removes the HTTP host, port, and path parameters and switches the transport to stdio (Figure 11).

# Before
server.run(transport="http", host="0.0.0.0", port=8888, path="/mcp")

# After
server.run(transport="stdio")

Modify server.run to use stdio transport
Figure 11 - Replace the server.run call with stdio transport

Save the file and close the text editor (Figure 12).

Save and close text editor
Figure 12 - Save main.py

Step 4 - Fix email validation and SSL certificate errors (optional)

The following video shows how to fix email validation and SSL certificate errors that may occur in certain environments. These modifications are only necessary if you encounter issues such as non-standard email addresses being rejected by the validator, or SSL certificate errors when connecting to a mail server without a valid certificate (for example, a locally hosted test server).

Open validator.py in a text editor. This file contains the function responsible for validating email addresses before a message is sent (Figure 13). This file can be found in the email-send-mcp/src/utils/ folder.

Open validator Python file
Figure 13 - Open the validator Python file

Replace the body of the validate_email_address function with the code below. This makes the function always return a valid result, bypassing strict email format checks that would otherwise reject non-standard or local domain addresses (Figure 14).

def validate_email_address(email: str) -> Tuple[bool, str]:
    return True, email

Modify email validator function
Figure 14 - Modify the email validator function

Save the file and close the text editor (Figure 15).

Save file and close text editor
Figure 15 - Save the validator file

Open email_receiver.py in a text editor. This file handles the IMAP connection used to retrieve incoming emails (Figure 16). This file can be found in the email-send-mcp/src/services/ folder.

Open email receiver Python file
Figure 16 - Open the email receiver Python file

Replace the hardcoded IMAP4_SSL connection with the conditional block below. This change makes the connection type respect the IMAP_USE_SSL setting in your .env file, allowing the server to connect without SSL when the setting is set to false (Figure 17).

if self.settings.IMAP_USE_SSL:
    imap = aioimaplib.IMAP4_SSL(
        host=self.settings.IMAP_SERVER,
        port=self.settings.IMAP_PORT
    )
else:
    imap = aioimaplib.IMAP4(
        host=self.settings.IMAP_SERVER,
        port=self.settings.IMAP_PORT
    )

Modify IMAP server connection code
Figure 17 - Replace the IMAP connection code

Save the file and close the text editor (Figure 18).

Save file and close text editor
Figure 18 - Save the email receiver file

Step 5 - Run MCP Inspector with the email server

The following video shows how to send an email using the Email Send/Receive MCP Server step-by-step. The video covers launching the MCP Inspector from the server folder, connecting to the email server, and executing the send email tool.

Open a terminal window in the MCP server folder. This is the same folder where you cloned the repository in step 1 (Figure 19).

Open terminal in email send MCP folder
Figure 19 - Open terminal in the MCP server folder

Run the command below to launch the MCP Inspector with main.py as the server entry point. The MCP Inspector will download its dependencies and open in your default web browser once ready (Figure 20).

npx @modelcontextprotocol/inspector python main.py

You need Node.js and NPM installed on your system to run this command. If you don't have Node.js installed, download it from nodejs.org before proceeding.

Run MCP Inspector with email server argument
Figure 20 - Execute MCP Inspector command with the email server

Step 6 - Connect to the email MCP server and list tools

In the MCP Inspector interface, the transport type will already be set to stdio. Click the Connect button to establish the connection between the MCP Inspector and the email server (Figure 21).

Connect to email MCP server
Figure 21 - Connect to the email MCP server

Once connected, click the List Tools button to display all available email automation tools provided by the server. The list will include tools for sending emails and retrieving messages from your inbox (Figure 22).

List available tools
Figure 22 - Display available email automation tools

Step 7 - Send an email

Locate and select the send_email tool from the available tools list. Clicking on it will expand the tool's parameter fields (Figure 23).

Select send email tool
Figure 23 - Select the send_email tool

Fill in the tool's parameter fields: enter the recipient's email address in the recipient field, a subject line in the subject field, and the message content in the body field (Figure 24).

Enter recipient, body and subject
Figure 24 - Enter recipient, subject and email body

Click the Run Tool button to send the email. The MCP server will connect to your configured SMTP host and deliver the message. A successful response in the Inspector confirms the email was sent (Figure 25).

Run tool to send email
Figure 25 - Execute the send_email tool

Open your email client to verify the result. The email sent through the MCP server should appear in the recipient's inbox, confirming the SMTP automation pipeline is working correctly (Figure 26).

Verify email received
Figure 26 - Verify the email was received in the mail client

Step 8 - Receive an email

The following video shows how to receive and read emails using the Email Send/Receive MCP Server. The video covers sending a test email to the configured account and retrieving it via the IMAP tool in the MCP Inspector.

To test email retrieval, first send a message to the account configured in the MCP server using any mail client. In this example, Thunderbird is used to compose and send a test email to the MCP account (Figure 27).

Send email to MCP account
Figure 27 - Send a test email to the MCP account

Back in the MCP Inspector, locate and select the receive_emails_imap tool from the tools list. This tool connects to your IMAP server and fetches messages from the inbox (Figure 28).

Open receive emails IMAP tool
Figure 28 - Select the receive_emails_imap tool

Click the Run Tool button to execute the retrieval. The MCP server will connect to your IMAP host and fetch the available messages from the inbox (Figure 29).

Run tool to retrieve emails
Figure 29 - Execute the receive_emails_imap tool

The tool response will display the retrieved emails including their sender, subject, and body content. This confirms the IMAP automation pipeline is working correctly and ready for integration into email processing workflows (Figure 30).

Emails retrieved
Figure 30 - Emails successfully retrieved from the inbox

Conclusion

You have successfully set up and tested the Email Send/Receive MCP Server for programmatic email automation. This integration enables you to send and receive emails through the Model Context Protocol interface, opening possibilities for AI-driven email workflows, automated notifications, inbox monitoring, and integration with AI assistants that support MCP. The server works with any standard IMAP/SMTP compatible email provider.


More information