Created
June 30, 2009 20:55
-
-
Save boosty/138420 to your computer and use it in GitHub Desktop.
Send all ActionMailer emails to a specific email adress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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'] = "[email protected]" # 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