Rails 3 sends emails in development to a single address

In my Rails 2 applications, I always used sanitize emails to send all emails to development to my personal account, to avoid accidentally sending emails or using them for testing purposes only.

This is not like the version of Rails 3 and wonders if there is anything for Rails 3 that does this.

+5
source share
2 answers

Take a look at How to intercept ActionMailer messages on rails 3? . You will need to add message.to = my@email, and mail will be sent to your email address instead of the original recipient.


This is what I ended up with a post related to above:

if Rails.env.development?
    class Hook
        def self.delivering_email(message)
            message.to  = "\"#{message.to.first}\" <my@email.com>"
            message.cc  = nil if !message.cc.nil?
            message.bcc = nil if !message.bcc.nil?
        end
    end

    ActionMailer::Base.register_interceptor(Hook)
end
+6
source

Ryan Bates (Railscasts) has just released an email processing gem for developers.

Letter_opener

Didn't use it, but probably worth a look.

+4
source

All Articles