An ActiveRecord based queue for email storage and delivery in Rails apps
Ruby JavaScript
Pull request Compare This branch is 45 commits behind cerebris:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config
lib
script
test
.gitignore
Gemfile
Gemfile.lock
MIT-LICENSE
README.rdoc
Rakefile
mailhopper.gemspec

README.rdoc

Mailhopper

Mailhopper provides a simple ActiveRecord-based queue for asynchronous delivery of email in Rails apps.

Why use Mailhopper to queue your email?

  • Mailhopper captures the full content and headers of emails at their time of creation. It can handle multiple MIME types and attachments.

  • If email can't be delivered from your queue (e.g. your smtp server is down), you can retry delivery until successful.

  • Emails can be accessed at any time, even after they've been sent.

Mailhopper is intended to be used along with a delivery agent such as DelayedMailhopper, which uses DelayedJob to deliver email from the Mailhopper queue. Without a delivery agent, emails will accumulate in the Mailhopper queue but won't be delivered.

Requirements

Rails 3.1+

Installation

Add to your project's Gemfile:

gem 'mailhopper'

Install with bundler:

bundle install

Generate default initializer and migration files:

rails generate mailhopper

Migrate your database:

rake db:migrate

Don't forget to also install a delivery agent, such as DelayedMailhopper, so that emails will be delivered from your queue !!!

Configuration

If you want all of your application's email to be queued with Mailhopper, configure mailers either in application.rb or your application's environment-specific configuration files:

MyApp::Application.configure do
  config.action_mailer.delivery_method = :mailhopper
end

Alternatively, or additionally, configure individual mailers to use Mailhopper:

class MyMailer < ActionMailer::Base
  ActionMailer::Base.delivery_method = :mailhopper
end

Options

The following options can be configured in your initializer (config/initializers/mailhopper):

Mailhopper::Base.setup do |config|
  # The base email class used by Mailhopper
  config.email_class = Mailhopper::Email

  # The base mailer class used by Mailhopper
  config.mailer_class = Mailhopper::Mailer

  # The method used by the delivery agent to deliver emails from your queue
  config.default_delivery_method = :smtp
end

It's preferable to leave these options out of your initializer if the defaults, shown above, are acceptable. Delivery agents may override some defaults (e.g. DelayedMailhopper sets email_class = DelayedMailhopper::Email).

Copyright

Copyright © 2011 Cerebris Corporation. This is free software released under the MIT License (see MIT-LICENSE for details).