In my Rails 2 apps I always used sanitize email to send all emails in development to my personal ac开发者_开发百科count to avoid accidentally sending out emails or to use just for testing.
This doesn't seem to have a Rails 3 version and wondered if there was anything for Rails 3 that does this.
Take a look at How to intercept ActionMailer's messages on rails 3?. You'll only have to add message.to = my@email
and the mail will be sent to your email address instead of the original destination.
This is what I ended up doing from the post linked 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
Ryan Bates(Railscasts) has just released a gem for handling dev emails.
Letter_opener
Haven't used it but probably worth a look.
精彩评论