Thursday, March 12, 2009

Multiple delivery method support for ActionMailer

For our test servers (and in development), I wanted to be able to create an action that would display all the emails sent by that mongrel. When using the :test delivery method, sent emails are readily available in ActionMailer::Base.deliveries. However, for our test server I wanted ActionMailer to send the email with smtp in addition to keeping them around in memory. So here's the resulting plugin:
ruby script/plugin install
Then in your development.rb (or environment.rb, or wherever) you can do this:
  config.action_mailer.delivery_method = [:test, :smtp]
I've tried it with Rails 2.1.0. No guarantees with any other version, or even 2.1.0 for that matter ;)

No comments: