Index / Blog / Emailbutler

Track Sent Emails in a Rails Application Using Open Source

Wouldn't it be great to have the functionality of a regular mailbox within your Rails application? If this thought has ever crossed your mind, we have good news. Our Ruby developer, Anton Bogdanov, created an email tracker called Emailbutler for Rails applications, which logs all emails sent through Action Mailer. The tracker comes with a user-friendly interface that allows you to sort and search through emails.

August 2024 2 mins

The main feature of Emailbutler is the ability to log all outgoing emails. If an email fails to send due to an error, it won't appear in the list. The UI allows you to easily work with the email list, filter, and search by recipients and actions.

 

Another useful feature is the collection of data from SMTP providers. The interface shows whether the email has been sent to the provider, delivered to the recipient, or opened. Spam markings are also displayed in the interface. At the time of publication, Emailbutler supports tracking the delivery status of emails sent through Sendgrid, SMTP2GO, Resend, and Mailjet.

Additionally, with Emailbutler, you can resend an email without manually re-entering the parameters. The interface includes a "Resend" button, which sends the email with the exact same parameters as the first time.

Installation

Add the following line to your application's Gemfile:

gem 'emailbutler'
gem 'pagy'

Then run:

$ bundle install

$ rails g emailbutler:active_record

$ rails db:migrate

Configuration

Initializer

Add the following configuration line to config/initializers/emailbutler.rb:

For Active Record:

require 'emailbutler/adapters/active_record'

Emailbutler.configure do |config|
  config.adapter = Emailbutler::Adapters::ActiveRecord.new # required
  config.providers = %w[sendgrid smtp2go resend mailjet] # optional
  config.ui_username = 'username' # optional
  config.ui_password = 'password' # optional
  config.ui_secured_environments = ['production'] # optional
end

Routes

Add this line to config/routes.rb:

mount Emailbutler::Engine => '/emailbutler'

UI Styles

To add styles for the UI, add the following line to assets/config/manifest.js:

//= link emailbutler.css

In some cases, you can specify this in assets/javascript/application.js:

//= require emailbutler_manifest

Mailers

Update the application's mailer:

class ApplicationMailer < ActionMailer::Base
  include Emailbutler::Mailers::Helpers
end

Webhook Settings for Providers

Sendgrid

  • Go to mail settings,
  • Enable Event Webhook,
  • In the HTTP POST URL field, insert the webhook controller URL of your application (host/emailbutler/webhooks/sendgrid),
  • Select all delivery data,
  • Save settings.

A similar procedure applies to other supported providers.

Usage

Each email-sending event will create a new record with the message parameters in the database. Each webhook event will update the message status in the database.

Future Plans

All the core features of Emailbutler are already implemented. We plan to clean up the logs and add new services for mail delivery. Currently, the tracker works with four providers: Sendgrid, SMTP2GO, Resend, and Mailjet.

Client Review

The idea for Emailbutler came about three years ago. We needed to figure out why a user didn't receive an email, what parameters it was sent with, and whether it could be resent. The provider couldn't give the necessary information, so we had to search through the application to see if the email was sent. That's when I thought we should log which emails were sent and with what parameters. And that's how this open source project was born.
Anton Bogdanov
Emailbutler Creator
Let’s talk about you
Attach file
Files must be less than 8 MB.
Allowed file types: jpg jpeg png txt rtf pdf doc docx ppt pptx.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.