A 2-phase database-driven ActionMailer delivery method.
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:
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
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:
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
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
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