Join us

How to Send Emails in VS Code with Mailtrap MCP Server

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 Mailtrap 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 DomainsIntegrationAPI, 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 Mailtrap Email MCP Server

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.

Wrapping it up

With the Mailtrap MCP server, you can send emails from your AI IDE without having to write a single line of code or leave your editor. This includes:

  • Plain-text emails
  • HTML emails
  • Emailing multiple recipients

If you want to learn more on how to send emails from VS code, check out the full version of this article on Mailtrap Blog.


Let's keep in touch!

Stay updated with my latest posts and news. I share insights, updates, and exclusive content.

By subscribing, you share your email with @idjuric660 and accept our Terms & Privacy. Unsubscribe anytime.

Give a Pawfive to this post!


Only registered users can post comments. Please, login or signup.

Start blogging about your favorite technologies, reach more readers and earn rewards!

Join other developers and claim your FAUN.dev account now!

Avatar

Ivan Djuric

Technical Content Writer, Mailtrap

@idjuric660
As a Technical Content Writer with 5 years of experience, I specialize in covering email-related topics, collaborating closely with software engineers and email marketers. My goal is to provide you with insights on email sending and testing.
Developer Influence
251

Influence

24k

Total Hits

32

Posts