Skip to content

Instantly share code, notes, and snippets.

@psugihara
Created May 10, 2016 22:08
Show Gist options
  • Save psugihara/3caa217486f86a848d6abf21d734b15e to your computer and use it in GitHub Desktop.
Save psugihara/3caa217486f86a848d6abf21d734b15e to your computer and use it in GitHub Desktop.
if Rails.env.staging? || Rails.env.development?
class MailFilter
def self.delivering_email(message)
message.to = message.to.reject {|recipient| recipient !~ /@openlistings.com/i }
if message.to.blank?
message.perform_deliveries = false
Rails.logger.debug "Interceptor prevented sending mail #{message.inspect}!"
end
message.subject = "[#{Rails.env.upcase}] " + message.subject
end
end
ActionMailer::Base.register_interceptor(MailFilter)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment