Skip to content

Instantly share code, notes, and snippets.

@mose
Last active December 21, 2015 08:28
Show Gist options
  • Save mose/6277853 to your computer and use it in GitHub Desktop.
Save mose/6277853 to your computer and use it in GitHub Desktop.
mail interceptor in rails
# lib/mailinterceptor.rb
class MailInterceptor
def self.delivering_email(message)
message.to = "dev@example.com"
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