Send emails with Cursor and Mailtrap

With the Cursor and Mailtrap integration, you can now send emails from Cursor.

Mailtrap is an email-sending solution for developer and product teams. Focused on fast delivery and high inboxing rates for transactional and promo emails. Provides highly customizable API and 24/7 tech support.

In this article, you’ll learn how to set it all up and start sending emails in three steps.

Prerequisites: 

  • If you haven’t set up your sending domain already, you’ll need to do it before we start—it takes ~5 minutes, and you can use our step-by-step article as a guide.
  • Install the latest Node.js version since Mailtrap MCP is implemented as a Node.js command line utility.
  • If you haven’t already done so, install the Cursor app. But if you have, make sure it’s updated and uses the latest version.

Step 1. Add Mailtrap MCP to Gemini

To add Mailtrap MCP to Gemini, you can use the quick install link or in your Cursor editor, navigate to Settings → Cursor Settings.

Go to the MCP tab and click on Add new global MCP server.

The Add new global MCP server should open a new mcp.json config file, where we’ll store the Mailtrap MCP configuration.

Tip: You can also open the mcp.json file in the following locations:

  • MacOS: ~/.cursor/mcp.json
  • Windows: %USERPROFILE%\.cursor\mcp.json

Once you open the mcp.json file, copy/paste the following configuration inside it:

{
  "mcpServers": {
    "mailtrap": {
      "command": "npx",
      "args": ["-y", "mcp-mailtrap"],
      "env": {
        "MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
        "DEFAULT_FROM_EMAIL": "your_sender@example.com"
      }
    }
  }
}

Note: In case you’re using asdf to manage Node.js, you must use an absolute path to the executable. Here’s an example for Mac:

{
  "mcpServers": {
    "mailtrap": {
      "command": "/Users/<username>/.asdf/shims/npx",
      "args": ["-y", "mcp-mailtrap"],
      "env": {
        "PATH": "/Users/<username>/.asdf/shims:/usr/bin:/bin",
        "ASDF_DIR": "/opt/homebrew/opt/asdf/libexec",
        "ASDF_DATA_DIR": "/Users/<username>/.asdf",
        "ASDF_NODEJS_VERSION": "20.6.1",
        "MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
        "DEFAULT_FROM_EMAIL": "your_sender@example.com"
      }
    }
  }
}

Step 2. Add Mailtrap API credentials

Open your Mailtrap account and navigate to Sending Domains → Integration → API.

​​Once in the Integration/API page, update the following values in your mcp.json file with Mailtrap credentials:

  • 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.

For example, here’s what your mcp.json file should ultimately look like:

And that’s it! Hit save, reload, and you can start sending emails via Cursor with simple prompts.

Step 3. Send emails with a prompt

First, toggle the AI Pane, located in the upper-right corner of the Cursor editor.

In the opened pane, make sure that the Agent mode is configured since it allows Cursor to perform actions for us.

To send a plain-text email, you can use a prompt like this one (although I encourage you to use your own prompts and experiment with them since the possibilities are pretty much endless):

Send an email to john.doe@example.com with the subject 'Hi John!' and a message that wishes John a great day.

Cursor will then identify the Mailtrap MCP server for your request, suggest running the right tool, in this case, send_email, and generate the email with all the parameters and values for you. As soon as you’re ready to send, click Run tool.

Lastly, Cursor AI will notify you when it successfully delivers the email.

And here is the generated message in the Mailtrap Email Logs.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us