Sha256: dd153269b95db696c24f11dd10badd30de95712236c6dee77492d99524720d23

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

# 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](https://www.mandrill.com/), [SendGrid](http://sendgrid.com), 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:

```ruby
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](https://raw.githubusercontent.com/humzashah/mail_rotator/master/samples/migration.rb.sample).

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](https://raw.githubusercontent.com/humzashah/mail_rotator/master/samples/mail_rotator.rb.sample). Add the limits, settings, any, additional services, and run the following rake task:

```ruby
bundle exec rake db:migrate mail_rotator:update_rows
```

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

```ruby
  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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mail_rotator-0.1.0 README.md