Last active
December 21, 2015 08:28
-
-
Save mose/6277853 to your computer and use it in GitHub Desktop.
mail interceptor in rails
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
# lib/mailinterceptor.rb | |
class MailInterceptor | |
def self.delivering_email(message) | |
message.to = "[email protected]" | |
message.subject = "[#{message.to}] " + message.subject | |
end | |
end | |
# config/initializers/setup_mail.rb | |
email_settings = YAML::load(File.open("#{Rails.root.to_s}/config/email.yml")) | |
Mail.register_interceptor(MailInterceptor) unless email_settings['live'].present? && email_settings['live'] == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment