VS Code

With the VS Code Mailtrap integration, you can send emails directly from Visual Studio Code using simple AI prompts powered by GitHub Copilot.

Mailtrap is an email-sending solution for developer and product teams focused on fast delivery and high inboxing rates for transactional and promo emails. It provides a highly customizable API and 24/7 technical support.

In this guide, you'll set up the integration and send emails in three steps.

Prerequisites

Before you start, ensure the following:

1

Add Mailtrap MCP to VS Code

To add Mailtrap MCP to VS Code, you can use the quick install link or follow these steps:

  1. Open VS Code and navigate to Settings

  2. Search for MCP in the settings search bar

  3. Tick the Chat > MCP: Enabled option

  4. Click Edit in settings.json

You can also open the settings.json file by typing Preferences: Open User Settings (JSON) in the Command Palette.

In your settings.json file, add the following code snippet:

settings.json
{
  "mcp": {
    "servers": {
      "mailtrap": {
        "command": "npx",
        "args": ["-y", "mcp-mailtrap"],
        "env": {
          "MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
          "DEFAULT_FROM_EMAIL": "[email protected]"
        }
      }
    }
  }
}
2

Add Mailtrap API credentials

Replace the following values in your settings.json file:

  • MAILTRAP_API_TOKEN — Authentication token for API requests. You can copy this from the Credentials tab in your Mailtrap account

  • DEFAULT_FROM_EMAIL — Must match your verified domain in Mailtrap's Sending Domains tab

Find these credentials in your Mailtrap account by navigating to Sending Domains → Integration → API.

Although you shouldn't face any issues, reload VS Code to ensure everything is set up correctly.

3

Send emails with a prompt

To send an email:

  1. Open the AI Pane in the upper-right corner of VS Code

  2. Make sure Agent mode is selected (this allows VS Code to perform actions)

  1. Open the list of available tools and select Mailtrap

  2. If you see similar MCPs from other editors (like Cursor), uncheck them

VS Code tools selection popup showing available MCP servers with Mailtrap send-email tool selected
  1. Use this prompt (or create your own):

Send an email to [email protected] with the subject 'Hi John!' and a message that wishes John a great day.

VS Code will identify the correct MCP server and suggest running the send-email tool. Click Continue to proceed.

The email will be sent successfully, and Copilot will confirm the action:

GitHub Copilot success message confirming that the email to John was sent successfully

Verify the email in your Mailtrap dashboard by checking the Email Logs tab:

Mailtrap Email Logs tab showing the Hi John email with delivery details and email status

Last updated

Was this helpful?