Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scrogson/e266ef4c4b75cfdefa84 to your computer and use it in GitHub Desktop.
Save scrogson/e266ef4c4b75cfdefa84 to your computer and use it in GitHub Desktop.
Intercept outgoing email in environments outside of production.
# config/initializers/sandbox_email_interceptor.rb
ActionMailer::Base.register_interceptor(SandboxEmailInterceptor) unless Rails.env.production?
# lib/sandbox_email_interceptor.rb
class SandboxEmailInterceptor
def self.delivering_email(message)
message.to = [Secrets.smtp["from"]]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment