Ruby
Overview
Mailtrap can be integrated with Ruby apps and projects for email sending.
Email API/SMTP for Ruby
SDK integration
The Mailtrap Ruby SDK has been significantly expanded. It now covers the full Mailtrap feature set — from batch sending and sandbox testing to contact management, templates, and more.
The Mailtrap Ruby SDK provides an idiomatic Ruby interface for sending transactional and bulk emails. The SDK supports:
Transactional email sending
Batch email sending
Template management
ActionMailer integration for Rails applications
Comprehensive error handling
Sandbox email sending and messages CRUD
Contacts management
Inboxes and Projects management
Account management
Installation
Add the SDK to your Gemfile:
Then run:
Minimal Example Ruby on Rails (Actionmailer)
Minimal Example Ruby
Here's a minimal example to send your first email:
Get your API token from your Mailtrap account under Settings → API Tokens.
SMTP integration
To integrate SMTP with your Ruby app, navigate to the Integrations tab, choose either Ruby on Rails or Ruby Net/SMTP, and copy-paste the credentials or ready-made code snippets.
SMTP integration is compatible with any Ruby framework or library that sends emails via SMTP.

Read more about SMTP integration in the Email API/SMTP - SMTP Integration article.
RESTful API integration
To integrate Mailtrap using RESTful API, use the configuration available among Code samples under the API section.
API integration can be used with any Ruby framework or library that supports HTTP requests. For more details, refer to the API documentation.

Read more about API integration in the Email API/SMTP - API Integration article.
Last updated
Was this helpful?

