Besides having an AI editor to help you develop projects, VS Code can now also generate and send emails in your stead.
To do this, you simply need to integrate VS Code with Mailtrap MCP and you’ll be able to send emails with a single prompt. And yes, this works for both Windows and macOS.
First, we’ll set up the MCP server, and then we’ll send emails.
Before we start: Mailtrap MCP server is implemented as a Node.js command line utility, so please install the latest Node.js version alongside the freshest version of VS Code editor.
Setup MCP Server
First, we’ll set up and configure an MCP Server in VS Code. So, open your VS Code editor, navigate to Settings, and use the search bar to find the Mcp tab. Then, tick the Chat> Mcp: Enabled option and click on Edit in settings.json.
This will open the settings.json file, which is used by VS Code to store the user settings and the MCP servers that you can make requests to. So, delete everything you find inside it and insert the following code snippet there:
{
"mcp": {
"servers": {
"mailtrap": {
"command": "npx",
"args": ["-y", "mcp-mailtrap"],
"env": {
"MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
"DEFAULT_FROM_EMAIL": "your_sender@example.com"
}
}
}
}
}
Here, we have added a new Mailtrap MCP configuration in the servers property, located inside the mcp property. However, if you have mcp-server-time in the servers configuration, you can either remove it, or install the mcp_server_time package to avoid errors when MCPs are loaded. If you want to install, you can do that by using the pip package manager (you will need Python installed).
pip install mcp_server_time
Essentially, VS Code can now use Mailtrap Email API to send emails. All there’s left to do is log in to your Mailtrap account, navigate to Sending Domains → Integration → API, find your credentials, and replace the following values:
MAILTRAP_API_TOKEN
– Used to authenticate API requests, which you can copy/paste from the credentials tab.DEFAULT_FROM_EMAIL
– Make sure the email’s domain matches your own domain from the Sending Domains tab in Mailtrap.
Note: Although you shouldn’t face any issues, I still recommend reloading VS Code to make sure everything is being set up correctly.
Send emails with MCP
To send an email, open the AI Pane of the VS Code editor in the upper-right corner. Then, in the opened pane, make sure Agent mode is selected, which allows VS Code to perform actions for us.
Next, open the list of available tools and select Mailtrap. If you see similar MCPs from other code editors (for instance, Cursor), make sure to uncheck them.
Finally, let’s try to send a plain-text email. You can test with the prompt below, but feel free to come up with your own prompts and experiment since the possibilities are aplenty. 🙂
Send an email to john.doe@example.com with the subject ‘Hi John!’ and a message that wishes John a great day. |
VS Code will then identify the right MCP server for your request, and suggest running the right tool in this case, send-email.
As soon as you’re ready, click Continue.
The plain-text email should be sent successfully, and the VS Code Copilot AI will notify you about.
You can verify it by checking the Email Logs tab of your Mailtrap dashboard.
Send HTML email
To send an HTML email in VS Code using Mailtrap MCP, all you need to do is tell the AI agent to format the message using HTML. For instance:
Send an email to john.doe@example.com with the subject ‘Hi John!’ and a message that wishes John a great day. Make sure the message is nicely formatted by using HTML. |
VS Code Copilot AI will then generate the message for you, with a new html
field that contains the HTML content of the email.
Once you’re ready, click Continue, and Copilot will send the new HTML email.
To verify whether the message has been properly formatted, visit the Preview tab in Mailtrap Email Logs.
Send email to multiple recipients
To send an email to multiple recipients, simply specify the addresses you want in the prompt. For example:
Send an email to Jackie and Michael with a simple greeting. Jackie’s email is jackie@example.com, and Michael’s email is mike@example.com. |
Again, you can verify that the email data meets your expectations. In this case, we can see a new cc field being specified, which includes a list of additional recipients provided via carbon copy.
Click Continue as soon as you’re ready.
A new email should be sent to multiple recipients, which you can verify by checking the Email Logs tab in Mailtrap.
Further reading: