Mailgun to Mailtrap:
A Migration Guide

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

Mailtrap and Mailgun Differences

  1. Your emails are stored under Mailtrap Email Logs for up to 30 days, depending on your pricing plan. We also store email content and hard data between 3 and 7 days.
  2. Mailtrap offers monthly recurring plans with an option to request annual billing/plan. Unlike Mailgun, Mailtrap doesn’t feature a pay-as-you-go plan, but we have a 1000-emails Free Forever plan to test out and evaluate our service.
  3. Mailtrap offers a Bulk Stream which allows you to send emails to many recipients at once (newsletters, marketing promotions, product updates, etc.).
  4. Mailtrap has a separate product – Mailtrap Email Testing – to test your emails in staging, check spam score, validate HTML and CSS, and inspect deliverability with different mailbox providers. Critically, Mailtrap Email Testing is only for testing emails in a safe environment without sending them to your recipients.
  5. You can’t schedule emails to be delivered later with Mailtrap.

Mailtrap and Mailgun – Similarities

  1. Support for sending with SMTP or REST API. 
  2. You can use return-path records and DKIM to verify a domain. 
  3. When sending from a newly added domain, the throughput gets queued or throttled.
  4. You can add a .csv file to import suppressed email addresses. 
  5. Both Mailgun and Mailtrap allow you to add unsubscribe options to emails without coding.    

Terminology comparison

  • Multi User Access
  • Mailgun Templates
  • Suppressions
  • Tags 
  • Webhooks
  • X-headers
  • X-Mailgun-Variables 

General step-by-step flow for migration

  1. After signing up for Mailtrap, select Sending Domains menu. Add your domain and proceed to verify it.

  2. If you choose SMTP service, switch the sending settings as per the credentials Mailtrap provides. See info under the SMTP header below.

  3. Should you select API integration, check API documentation and Mailtrap libraries.

  4. Take the time to understand the main differences between Mailgun and Mailtrap as shown above.

    Need some help?

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

  5. If you need to send more than 200K emails a month, don’t hesitate to get in touch with Mailtrap support. We’ll schedule a call with you to make sure you transition properly.

    Mailtrap Tip

    Use ActionMailer Balancer Ruby gem to proportionally distribute the email sending load between two different sending services (e.g. 60% Mailgun and 40% Mailtrap) to mitigate the sending risks.

Getting started

It doesn’t take much to get started with Mailtrap. You only need to create an account then proceed to set up and verify your domain from the Sending Domains menu. Check our Getting Started Guide for more information and here is a quick walk-through on how it goes.

Domain verification

  • After you sign up, then add and verify your domain, it undergoes a security check, which usually takes two business days. During that time, your throughput is limited to 50 emails per hour to prevent system abuse. Read our article on Sending Limits to learn more. 
  • It’s critical not to delete and re-add during the security check as it’ll be regarded as suspicious behaviour. 
  • You can get the limitation lifted with a support ticket where you’ll be asked to answer a few questions to prove your domain’s trustworthiness. 
  • Make sure you set unsubscribe options with Mailtrap and import your suppression lists from Mailgun. 

SMTP

SMTP Endpoints

Mailgun Server (EU) Mailgun Server (US)
live.smtp.mailtrap.io
bulk.smtp.mailtrap.io
smtp.eu.mailgun.orgsmtp.mailgun.org

SMTP Ports

PortFunction
587The recommended SMTP relay with TSL. 
25High traffic, blocked by some mailbox providers due to abuse.
2525Alternative port, in case you encounter issues with other ports. 
465For SSL SMTP connection

SMTP Configuration

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

Copy-paste the credentials (for the stream you chose) in to your app or project, and proceed to send a confirmation email to verify the setup. Check our Sending Domain Setup article for more information on how to do it.

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

API

Mailtrap API tokens

Mailtrap automatically creates a token when you create a domain, and the token has a Domain Admin access permission by default. You can Edit permissions for that token to authorize it with other domains on your account.

For more information on how to manage API tokens, check our guide.

API Mapping

API typeMailtrapMailgun
The BasicsGeneralIntroduction
SendingSend emailMessages
Email TestingEmail Testing API

API Libraries

At the moment there are five libraries available at Mailtrap.

Programming LanguageMailtrapMailgun
NodeJSNodeJS SDKMailgunJS
RubyRuby SDKMailgun Ruby Gem
PHPPHP SDKMailgunPHP
PythonPython SDKNot supported
ElixirElixir SDKNot supported

API Authentication

Mailtrap uses Bearer authentication. So, you need to pass the API token under Authorization header of your email.

User management

Starting from the Business plan, you can add users to your account and manage their permissions. Clicking on User Management under Settings reveals all users in a particular account where you can easily add new members and assign their permissions.

Based on the permissions users get, they’ll be able to view, access, and/or modify specific functionalities of an app. 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.