MailRotator :mailbox:

What is this?

The short version: This is a Ruby gem intended to be used with Rails projects.

The not-so-short version: Mandrill, SendGrid, and similar services are free for the first few emails. But once you've exhausted your period quota, you have to pay! :moneybag:

So why not string such services together and use the free email quota each one of them provides? With this tool, you can assign different quotas to your mail service accounts. Once a particular account reaches its limit, the next one will kick in!

Thus you can use this to not pay anything to send email or simply to rotate your email servers.

Usage

Add like any other gem:

gem 'mail_rotator'

followed by bundle install.

The sent mails are tracked through a database table. So you will need to create a migration with the contents of this file.

Define the SMTP settings of each of your services in any initializer e.g. config/initializers/mail_rotator.rb. You can get a template for the initializer here. Add the limits, settings, any, additional services, and run the following rake task:

bundle exec rake db:migrate mail_rotator:update_rows

Go to the mailer you are using and prepend the MailRotator module:

  class CustomMailer < ActionMailer::Base
    prepend MailRotator # which implies that you should have Ruby 2.0.0+
  end

You're done! :clap:

Get in touch

You can report an issue if there is a bug; for collaborations, create pull-requests; to offer me pizza, email me! :pizza: humzashah [at] gmail [dot] com