From fe87fa8dcb6041c85bb6874b25605b513bfea0a5 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 20 Jan 2015 14:23:51 -0500 Subject: [PATCH] use mail_interceptor --- Gemfile | 3 +++ Gemfile.lock | 2 ++ config/initializers/setup_email.rb | 5 +++++ config/settings.yml | 3 ++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 95c0c74..ab10c4d 100644 --- a/Gemfile +++ b/Gemfile @@ -60,6 +60,9 @@ gem 'browser' # haml as templating engine gem 'haml-rails' +# intercepts outgoing emails in non-production environment +gem 'mail_interceptor' + # HTTP server for Rack applications for staginng and production # See https://github.com/bigbinary/wheel/issues/43 for why unicorn is # not used in development. diff --git a/Gemfile.lock b/Gemfile.lock index 9b99a82..64a0b36 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -151,6 +151,7 @@ GEM kgio (2.9.2) mail (2.6.3) mime-types (>= 1.16, < 3) + mail_interceptor (0.0.1) mime-types (2.4.3) minitest (5.5.0) minitest-reporters (1.0.8) @@ -271,6 +272,7 @@ DEPENDENCIES honeybadger jbuilder (~> 1.2) jquery-rails + mail_interceptor minitest-reporters pg quiet_assets diff --git a/config/initializers/setup_email.rb b/config/initializers/setup_email.rb index d43aa8d..dd0f817 100644 --- a/config/initializers/setup_email.rb +++ b/config/initializers/setup_email.rb @@ -5,3 +5,8 @@ if Settings.mailer.delivery_method == :smtp ActionMailer::Base.smtp_settings = Settings.mailer.smtp_settings end + +interceptor = MailInterceptor::Interceptor.new({ forward_emails_to: Settings.intercept_and_forward_emails_to, + deliver_emails_to: ["@company.com"], + subject_prefix: Settings.subject_prefix_for_outgoing_emails }) +ActionMailer::Base.register_interceptor(interceptor) diff --git a/config/settings.yml b/config/settings.yml index d7e0046..9096cb4 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -1,5 +1,6 @@ common: + subject_prefix_for_outgoing_emails: WHEEL secret_key_base: <%= ENV['SECRET_KEY_BASE'] %> honeybadger_api_key: <%= ENV['HONEYBADGER_API_KEY'] %> host: <%= ENV['APP_URL'] || ENV['HEROKU_URL'] || 'http://localhost:3000' %> @@ -78,4 +79,4 @@ production: enable_starttls_auto: true support_email: - support@example.com \ No newline at end of file + support@example.com