Sending email can be a bottleneck in your Rails app. Here's a dead simple way of making all your mail be delivered asynchronously.
With the plugin installed, all mail send from Mailer gets put into a table called QueuedMails. Here's my migration to add that table:
class AddQueuedMailTable < ActiveRecord::Migration
create_table :queued_mails do |t|
t.column :object, :text
t.column :mailer, :string
endNow everytime you call
YouMailer.deliver_something(*params)that mail object will be stored in the QueuedMails table. Just periodically call script/runner from a cron job to process your new mail queue:
"script/runner 'MailQueue.process' -e production"If you want to bypass the queue just called the deliver_method_name with an exclamation point at the end. Like:
This feature to bypass the queue isn't the same way it was done in the original release of this plugin, so it isn't backwards compatible. Not a huge thing to change, and it probably wasn't a very popular thing used by people using this plugin anyways.
Nate, Inkling Inc., http://www.inklingmarkets.com
These details are provided for information only. No information here is legal advice and should not be used as such.