Cursor

Integrate Mailtrap with the Cursor code editor to send transactional and promotional emails directly from your AI-powered development environment.

Cursorarrow-up-right is an AI coding platform that understands your entire codebase and lets you write, edit, and refactor code across multiple files with natural language commands.

In this guide, you’ll learn how to:

Click on any of the links above to jump ahead to the detailed step-by-step section.

Integrate Mailtrap with your Cursor project

Step 1. Get your API token

You need an API token to authenticate all Mailtrap API calls — sending emails, managing domains, creating templates.

Go to API Tokensarrow-up-right → create a new token with Admin access to your account → copy the token value.

Step 2. Verify your domain

Before you start sending emails with Mailtrap, you first need to verify your domain. The process takes ~15 minutes, and you can do it manually, by following our step-by-step guidearrow-up-right or programmatically, by prompting the Cursor AI assistant.

  • Add your domain to Mailtrap

The response will include all DNS records you need to add.

  • Add DNS records at your registrar

Most domain registrars have APIs your AI assistant can use to add these records automatically. Provide your registrar's API credentials and let it handle the rest.

  • Check DNS propagation

Use dig to verify records have propagated before triggering verification in Mailtrap:

circle-info

DNS propagation usually takes minutes but can take up to 48 hours. If dig returns the expected values, records are ready. You can also click Verify DNS Records on your domain in Sending Domainsarrow-up-right to trigger a check from Mailtrap's side.

  • Check verification status via API

Poll the domain until dns_verified is true:

Each record in the dns_records array has a status field: pass, fail, or unchecked. When all records show pass, your domain is verified.

circle-info

After DNS verification, newly added domains undergo a compliance check. Your domain's compliance_status will progress from under_reviewawaiting_questionnairecompliant. If the status stays at awaiting_questionnaire, check your domain details in Sending Domainsarrow-up-right — you may need to click Fill in Compliance Form and provide additional information about your sending practices.

Step 3. Prompt the Cursor AI assistant

You can prompt Cursor to integrate Mailtrap into your project, have AI install the right SDK (if available), and help to write the actual sending code with a prompt like this one:

Integrate Mailtrap into my project, so that it can send emails through the Mailtrap email API. For this, use my Mailtrap API token and sending address. Make sure to safely store my credentials in an .env file

Important: Don't forget to add your actual Mailtrap API token and the sending email address to the prompt.

Cursor AI will then go through the Mailtrap documentation, integrate the email API, and safely store your credentials in a .env file. Then, you can proceed to test the configuration. For instance, here’s our contact form email in our Gmail inbox we used as our to address:

And here is the same email in the Mailtrap Email Logsarrow-up-right:

Add Mailtrap MCP to Cursor

Note: Before you start, make sure to install the latest Node.js versionarrow-up-right since Mailtrap MCParrow-up-right is implemented as a Node.js command line utility.

To add Mailtrap MCP to Cursor, simply click herearrow-up-right or press the quick install button on the official Mailtrap MCP page:

You will then be taken to the following Cursor settings page, where you will have to insert your Mailtrap credentials:

  • MAILTRAP_API_TOKEN – Required for all functionality, used to authenticate API requests, which you can copy/paste from the credentials tab.

  • DEFAULT_FROM_EMAIL – Required for email sending. Make sure the email’s domain matches your own domain from the Sending Domains tab in Mailtrap.

You can find these credentials in your Mailtrap account by navigating to Sending DomainsIntegrationAPI.

  • MAILTRAP_ACCOUNT_ID – This is required for template management purposes. You can find the account ID under SettingsAccount Settings.

  • MAILTRAP_TEST_INBOX_ID – If you need sandbox email functionality, you can find this ID in your Sandbox.

Once you insert your Mailtrap credentials, make sure to hit the Install button, and you should see Mailtrap MCP installed, along with a list of available tools it comes with. Currently, Mailtrap MCP supports:

  • Sending: send live emails

  • Sandbox: list and preview test inbox messages

  • Email logs: filter delivery history by sender, recipient, status, or event; view a specific log with optional raw body

  • Stats: get delivery, bounce, open, click, and spam rates over a date range, broken down by domain, category, ESP, or date

  • Templates: list, create, update, delete email templates

  • Sending domains: list, create, delete domains, plus get verification status and DNS setup instructions

Install Mailtrap Skills in Cursor

With Mailtrap Skillsarrow-up-right, your Cursor AI agent can get correct Mailtrap endpoints, auth patterns, and stream choices without you having to leave the editor. To install them, simply copy symlink the skill folders into the skills directory your agent reads. For example:

  • Cursor (project): .cursor/skills/ in your repo, e.g. ln -s /path/to/mailtrap-skills/skills/* .cursor/skills/

  • Cursor (user): ~/.cursor/skills/ for global availability

Note: Mailtrap Skills are not a substitute for docs.mailtrap.ioarrow-up-right or the developer API documentationarrow-up-right.

Last updated

Was this helpful?