I would like to turn off certain emails in development and on test/staging servers, but keep sending them in production. What I currently do is set the default “to” address for these administrative mails to blank:
default :to => Rails.env.production? ? "admin-list@sharethevisit.com" : ""
However, this puts stack traces in my development log when I’m testing the user mails which should be sending.
Is there a more effective way of disabling certain emails based on the current environment? I tried checking in the functions themselves, but is not ideal because I have to change each function, plus it doesn’t actually work… it just fails to set the needed @account variable before rendering the email and creating a different stack trace.
def user_registered_notify_email(account)
if Rails.env.production?
@account = account
mail(:subject => "New user registered: #{@account.full_name}")
end
end
I usually use mail interceptors as described here: http://asciicasts.com/episodes/206-action-mailer-in-rails-3