SendGrid To Mailtrap:
A Migration Guide

This guide covers core principles of how to migrate from SendGrid to Mailtrap seamlessly: terminology comparisons, SMTP, or API Configurations, and other tech specifications needed for the smooth switch.

Key Differences Between SendGrid and Mailtrap

  1. Depending on the pricing plan, Mailtrap stores emails in the Email Logs for up to 30 days. Email content and historical data is stored and accessible between 3 and 7 days without any additional fees.
  2. You can request annual billing/plan with Mailtrap, not only monthly-billed plans.
  3. Mailtrap offers Email Testing. This is a separate product to inspect HTML/CSS, spam scores, etc. and debug emails in staging, dev, and QA environments before sending them to recipients.
  4. Mailtrap doesn’t have the scheduled for later email sending option.

Terminology comparison

  • Teammates
  • SendGrid Templates
  • Suppressions
  • Categories
  • Webhooks
  • X-SMTPAPI
  • unique_args

General step-by-step flow for migration

  1. Sign up for Mailtrap, add your sending domain under Sending Domains menu and verify it. See our Getting Started Guide for more details.

  2. If you use SMTP service, change your settings accordingly.

  3. If you use API, check our libraries and API documentation.

  4. Make sure you understand the key differences between SendGrid and Mailtrap mentioned above.

    Need some help?

    Contact our support and our tech experts will help you with it.

  5. In case you plan to send more than 200k emails a month – contacting Mailtrap support is much recommended. We are also happy to help, just schedule a call with a member of our team and we’ll make sure your migration is done correctly.

    Mailtrap Tip

    You can use ActionMailer Balancer Ruby gem to proportionally distribute the email sending load between two different sending services (e.g. 70% SendGrid and 30% Mailtrap) to mitigate the sending risks.

Getting started

To start sending emails with Mailtrap, you only need to create an account, then register, and verify your domain. Domain setup and verification is done from the Sending Domains menu.

Domain verification

  • After you create an account and add your sending domain, it will take up to two business days to go through the security check.
  • Make sure not to make any add-ons, fixes, and other alterations during the domain verification time since it could be seen as suspicious behavior.
  • Until the domain is verified, the throughput of sending is limited to 50 emails per hour to prevent abusing the system with spam activities. Learn more about it in our Sending Limits article.
  • The sending limits could be lifted by contacting the Mailtrap support team. In this case, you will have to provide answers to a number of questions to prove the trustworthiness and authority of your sending domain.

Sending with Mailtrap SMTP

SMTP Endpoints

live.smtp.mailtrap.io
bulk.smtp.mailtrap.io
smtp.sendgrid.net

SMTP Ports

PortFunctionMailtrap supportSendGrid support
587recommended for encrypted TLS SMTP connection
25May be problematic due to blocking by some mailbox providers to avoid abuse
2525For unencrypted/TLS

SMTP Configuration

After signing up and verifying your sending domain, select that domain and go to the SMTP/API Settings tab. Then, choose Transactional or Bulk Stream depending on the type of emails you’d like to send.

Copy and paste the SMTP credentials (for the stream you chose) into your app.

Note: Turning TLS on is mandatory as mentioned in the credentials.

Sending with Mailtrap API

Mailtrap API tokens

When you create a domain, a token is automatically created and named based on the following formula: [domain name] + [token] + [token ID]. Add or remove token permissions in the API Tokens menu under Settings.

Learn more on how to manage API tokens in our guide.

API Mapping

API typeMailtrapSendGrid
Email sendingSend emailMail
User managementUser managementTeammates
Email TestingEmail Testing API

API Libraries

At the moment there are five libraries available at Mailtrap.

Programming LanguageMailtrapSendGrid
NodeJSNodeJS SDKNodeJS
RubyRuby SDKRuby
PHPPHP SDKPHP
PythonPython SDKPython
ElixirElixir SDKNot supported

API Authentication

We use Bearer authentication. Pass the API token into the code under the header Authorization.

Permissions/User management

You can add users to your account and manage their permissions if you are signed up for the Business price plan or higher. To add users, and assign and edit their permissions, click on the User Management menu under Settings, then the three dots on the right.

Note that a user needs Admin permissions to get authenticated and send emails via API.

Read more about managing users permissions

ActionMailer Balancer for smooth migration

For Ruby on Rails applications, Mailtrap offers ActionMailer Balancer that makes the migration smooth. ActionMailer extension allows proportionally distributing the email sending load between two different sending services and mitigating the sending risks.

After you install the Balancer to your application, and do some minor configurations, it will extend the sending method of ActionMailer.

For more detailed info on the boilerplate and use in development, read the Mailtrap ActionMailer Balancer Github page.