Override ActionMailer's mail to address in development environment

I use an ActionMailer interceptor so all mails sent while in development or test environments are sent to the same address. Like this:

# config/initializers/override_mail_recipient.rb
if Rails.env.development? or Rails.env.test?
  class OverrideMailRecipient
    def self.delivering_email(mail)
      mail.to = '[email protected]'
    end
    ActionMailer::Base.register_interceptor(OverrideMailRecipient)
  end
end

I think the best option is to use a service like mailtrap.io: http://mailtrap.io or mailcatcher gem: https://rubygems.org/gems/mailcatcher


What I like to do is configure action mailer in the development environment to use mailtrap.