Skip to content

Instantly share code, notes, and snippets.

@ushu
Last active December 28, 2015 10:08
Show Gist options
  • Save ushu/7483717 to your computer and use it in GitHub Desktop.
Save ushu/7483717 to your computer and use it in GitHub Desktop.
Rails mailer interceptor for DEV
# lib/development_mail_interceptor.rb
# copied from some RailsCast (could not remember the #...)
# expects a DEVELOPMENT_REDIRECT_EMAIL env var
class DevelopmentMailInterceptor
def self.delivering_email(message)
message.subject = "#{message.to} #{message.subject}"
message.to = ENV['DEVELOPMENT_REDIRECT_EMAIL']
end
end
# config/initializers/development_mail_interceptor.rb
if Rails.env.development?
require 'development_mail_interceptor'
Mail.register_interceptor(DevelopmentMailInterceptor)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment