Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A 2-phase database-driven ActionMailer delivery method

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 lib
Octocat-spinner-32 tasks
Octocat-spinner-32 README.textile
Octocat-spinner-32 deliver_later.gemspec
Octocat-spinner-32 init.rb
Octocat-spinner-32 install.rb
README.textile

DeliverLater

A 2-phase database-driven ActionMailer delivery method.

Usage

Install the plugin:

$ ./script/plugin install git://github.com/mtodd/deliver_later.git

This will automatically call the Rake task to run the migration. If you do not
run the installer (such as cloning it manually), be sure to run the install
task like this:

$ rake deliver_later:install

Now that the plugin is installed, you’ll want to enable the deferred delivery
in your application. Edit your environment file (such as
config/environments/production.rb if you want to add this to your production
environment) and change the delivery method from something like :smtp to
:smtp_later.

config.actionmailer.delivery_method = :smtp_later

This will enable the 2-phase delivery in the system and begin queueing emails.

To enable the 2nd phase delivery, you will want to set up a cron task as:

/path/to/app/current/script/runner ‘QueuedMailing.deliver_queued!’

Of course you will need the rest of the standard cron information such as
timing, user, etc.

There’s an alternative method to QueuedMailing.deliver_queued! which adds
calls an exception on any failed emails so that your Exception Notifier can
then send a notification of the failure. This method can be called with
QueuedMailing.deliver_queued_with_notification_on_failure!.

If all of your emails have been sent successfully, you can periodically run the
QueuedMailing.purge_sent! method via ./script/runner to delete any
successfully delivered emails.

Emails have problems being sent (an exception is raised in the process of
delivery) are marked as read and the exception message and backtrace are saved
with the email.

When you call QueuedMailing.deliver_queued!, emails that were problematic are
also included in the emails to retry automatically.

License & Copyright

The MIT License

Copyright © 2008 Matt Todd, Highgroove Studios.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Something went wrong with that request. Please try again.