Skip to content

Instantly share code, notes, and snippets.

@boosty
Created June 30, 2009 20:55
Show Gist options
  • Save boosty/138420 to your computer and use it in GitHub Desktop.
Save boosty/138420 to your computer and use it in GitHub Desktop.
Send all ActionMailer emails to a specific email adress
# Want your Rails app to send all ActionMailer emails
# to a specific email adress instead of sending it
# to the world (e.g. in the staging environment)?
#
# Put this into e.g. config/environments/staging.rb
config.after_initialize do
module ::ActionMailer
class Base
class_eval do
def deliver_with_overwritten_recipients!(mail = @mail)
mail['cc'], mail['bcc'] = nil, nil
mail['to'] = "info@example.com" # All emails will go here
deliver_without_overwritten_recipients!(mail)
end
alias_method_chain :deliver!, :overwritten_recipients
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment