I have an interceptor in place to keep the emails getting sent to real users' emails. This works great on our dev and staging environments. However, when generating an email locally from the rails console, the interceptor does not intercept and the email ends up actually getting delivered to the email from the DB and not from the interceptor.
The work around is to pass a proc as the interceptor instead of setting the interceptor_params.
Here is our mailer config file:
MandrillMailer.configure do |config|
config.api_key = ENV['MANDRILL_APIKEY']
unless Rails.env.production?
# This was our existing setup that did not intercept when executing from the console
# config.interceptor_params = {to: [{ email: ENV['INTERCEPTING_RECIPIENT'] }] }
# This works on dev, staging, and from the console
config.interceptor = Proc.new {|obj| obj[:to] = [{email: ENV['INTERCEPTING_RECIPIENT']}] }
end
end
I have an interceptor in place to keep the emails getting sent to real users' emails. This works great on our dev and staging environments. However, when generating an email locally from the rails console, the interceptor does not intercept and the email ends up actually getting delivered to the email from the DB and not from the interceptor.
The work around is to pass a proc as the interceptor instead of setting the interceptor_params.
Here is our mailer config file: