Send Emails with Windsurf and Mailtrap

This article provides a comprehensive guide based on Mailtrap's official tutorial on how to send emails in Windsurf.
Before we start
Required accounts
Windsurf account - to access the AI-powered development environment
Mailtrap account - to send emails
Node.js - latest version installed for MCP server functionality
Prerequisites setup
Verify your email sending domain - Mailtrap requires domain verification before you can send emails. This process takes approximately 5 minutes and ensures optimal deliverability rates. Follow Mailtrap's domain setup guide for detailed instructions.
Get your API Token - Navigate to your Mailtrap dashboard and obtain an API token with appropriate permissions for your sending domain and email operations.
Install Windsurf - Download and install the latest version of Windsurf from windsurf.com to ensure compatibility with all MCP features.
Update Node.js - Ensure you have the latest Node.js version installed, as the Mailtrap MCP server runs as a Node.js command line utility.
Important Note: The integration uses Mailtrap's MCP server, which provides a seamless interface between Windsurf's AI capabilities and Mailtrap's email infrastructure.
Configure Mailtrap Integration with Windsurf
Step 1: Add Mailtrap MCP to Windsurf
Begin by configuring the MCP server connection in Windsurf:
Open Windsurf Settings
Launch Windsurf application
Navigate to Settings → Windsurf Settings
This will open the main configuration panel
Access MCP Configuration
Look for the Manage MCPs button in the settings panel
Click on it to open the mcp.config.json file
This file controls all Model Context Protocol integrations
Add Mailtrap MCP Configuration
Insert the following configuration into your mcp.config.json file:
{
"mcpServers": {
"mailtrap": {
"command": "npx",
"args": ["-y", "mcp-mailtrap"],
"env": {
"MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
"DEFAULT_FROM_EMAIL": "your_sender@example.com"
}
}
}
}
This configuration establishes the connection between Windsurf and Mailtrap's email services through the MCP protocol.
Step 2: Configure Mailtrap API Credentials
Replace the placeholder values in your configuration with your actual Mailtrap credentials:
MAILTRAP_API_TOKEN Configuration
Navigate to your Mailtrap dashboard
Go to Sending Domains → Integration → API
Copy your API token from the credentials tab
Ensure the token has appropriate permissions for email sending
DEFAULT_FROM_EMAIL Setup
Use an email address from your verified sending domain
The domain must match exactly with your verified domain in Mailtrap
Format: sender@your-verified-domain.com
Verify Domain Matching
Check your Sending Domains tab in Mailtrap
Ensure the email domain you're using is verified and active
Mismatched domains will result in delivery failures
Important: After updating your credentials, restart Windsurf to ensure all changes take effect properly. This prevents any caching issues with the MCP server connection.
Step 3: Enable Mailtrap MCP in Windsurf
Activate the Mailtrap integration within your Windsurf workspace:
Open Cascade Sidebar
Locate the Cascade panel in the upper-right corner of Windsurf
This is where you'll interact with AI assistance and MCP servers
Enable Mailtrap MCP Server
Look for Customizations section in the Cascade sidebar
Find the Mailtrap MCP server in the available integrations
Toggle it to enabled status
This allows Windsurf to perform email actions through Mailtrap
Verify Connection Status
The enabled MCP server should show as connected
You may see a green indicator or status message
If connection fails, double-check your API credentials
Send Your First Email with Windsurf and Mailtrap
Step 1: Basic email sending
With your integration configured, you can now send emails using natural language prompts. Example Prompt:
Send an email to john.doe@example.com with the subject 'Welcome to our service' and a message thanking them for signing up.
Windsurf will interpret this prompt and execute the email sending through Mailtrap automatically.
Step 2: Advanced email features
Leverage more sophisticated email functionality with detailed prompts. HTML Email Example:
Send an HTML email to customer@example.com with the subject 'Monthly Newsletter' including a header with our company logo, a welcome message, and a call-to-action button linking to our website.
Multiple Recipients Example:
Send a notification email to team@company.com and manager@company.com with the subject 'Project Update' and a status report about the current development progress.
Step 3: Verify Email Delivery
After sending emails through Windsurf, confirm successful delivery:
Check Windsurf Confirmation
Windsurf will display a success message after email execution
Review the prompt response for any error messages
Monitor Mailtrap Dashboard
Navigate to Email Logs in your Mailtrap account
Verify the email appears in the sent logs
Check delivery status and any bounce notifications
Test Email Receipt
Check the recipient's inbox for successful delivery
Verify email formatting and content accuracy
Windsurf Email Integration Best Practices
Environment Management
Store sensitive API tokens securely in the MCP configuration
Regularly rotate your Mailtrap API tokens
Never commit API credentials to version control systems
Domain Verification
Always use verified sending domains to ensure high deliverability
Monitor your domain reputation through Mailtrap analytics
Keep DNS records updated and properly configured
Sender Reputation
Use consistent sender addresses from verified domains
Monitor bounce rates and spam complaints in Mailtrap dashboard
Maintain clean recipient lists to avoid delivery issues
Content Quality
Craft clear, relevant subject lines to improve open rates
Use proper HTML structure for formatted emails
Include both HTML and plain text versions when possible
Avoid spam trigger words and excessive promotional content
Prompt Engineering
Start with simple email prompts and gradually increase complexity
Be specific about recipient, subject, and message content
Use descriptive language for HTML formatting requirements
Test prompts iteratively to refine email output
Summing up
This comprehensive guide demonstrates how to integrate Mailtrap Email Delivery Platform with Windsurf using MCP server. The integration enables developers to send transactional emails through natural language prompts without complex coding.
Subscribe to my newsletter
Read articles from Ivan Djuric directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Ivan Djuric
Ivan Djuric
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 thoroughly researched and actionable insights on email sending, testing, deliverability, and beyond. I'm eager to lend you a hand in navigating the intricate world of emails!