Skip to content

Instantly share code, notes, and snippets.

@dpaluy
Created March 10, 2024 05:28
Show Gist options
  • Save dpaluy/3388fce2ea56a54062bdca5c71cc5975 to your computer and use it in GitHub Desktop.
Save dpaluy/3388fce2ea56a54062bdca5c71cc5975 to your computer and use it in GitHub Desktop.
Rails staging email interceptor
# config/initializers/email_interceptors.rb
if Rails. env.staging?
ActionMailer::Base.register_interceptors(Interceptors::StagingEmailInterceptor)
end
# app/mailers/interceptors/staging_email_interceptor.rb
class Interceptors::StagingEmailInterceptor
def self.delivering_email(email)
email.to = "devs@example.com"
email.subject = "(TEST)" + email.subject
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment