Skip to content

Commit

Permalink
Update mail_interceptor settings
Browse files Browse the repository at this point in the history
 - Updated mail_interceptor gem, added email_prefixer for prefixing
   emails.
 - Added initializer for email_prefixer and updated interceptor settings to
   register interceptor conditionally so that it won't be registered in
   test and production environments.
  • Loading branch information
prathamesh-sonpatki committed May 16, 2015
1 parent 98f46d4 commit f9f905f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ gem 'browser'
gem 'haml-rails'

# intercepts outgoing emails in non-production environment
gem 'mail_interceptor'
gem 'mail_interceptor', github: 'bigbinary/mail_interceptor', group: [:development, :staging]

# Adds prefix to the subject in emails
gem 'email_prefixer'

# HTTP server for Rack applications for staginng and production
# See https://github.com/bigbinary/wheel/issues/43 for why unicorn is
Expand Down
14 changes: 11 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ GIT
ransack (~> 1.3)
sass-rails

GIT
remote: git://github.com/bigbinary/mail_interceptor.git
revision: 3c6e9689e78a8edbf589d284b03a0146af421847
specs:
mail_interceptor (0.0.5)
activesupport

GIT
remote: git://github.com/mhfs/devise-async.git
revision: f8f61910e6ef54fdc91ebf5088c0594be9dca19c
Expand Down Expand Up @@ -110,6 +117,8 @@ GEM
thread_safe (~> 0.1)
warden (~> 1.2.3)
docile (1.1.5)
email_prefixer (1.1.0)
rails (>= 4.0)
email_validator (1.5.0)
activemodel
erubis (2.7.0)
Expand Down Expand Up @@ -167,8 +176,6 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mail_interceptor (0.0.3)
activesupport
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
Expand Down Expand Up @@ -303,14 +310,15 @@ DEPENDENCIES
delayed_job_web (>= 1.2.0)
devise (= 3.4.1)
devise-async!
email_prefixer
email_validator
font-awesome-sass (~> 4.3.0)
haml-rails
handy
honeybadger
jbuilder (~> 1.2)
jquery-rails
mail_interceptor
mail_interceptor!
minitest-reporters
pg
quiet_assets
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/email_interceptor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if Settings.intercept_and_forward_emails_to.present?
options = { forward_emails_to: Settings.intercept_and_forward_emails_to,
deliver_emails_to: ['@example.com'] }

interceptor = MailInterceptor::Interceptor.new(options)
ActionMailer::Base.register_interceptor(interceptor)
end
3 changes: 3 additions & 0 deletions config/initializers/email_prefixer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EmailPrefixer.configure do |config|
config.stage_name = 'WHEEL'
end
5 changes: 0 additions & 5 deletions config/initializers/setup_email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@
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)
3 changes: 0 additions & 3 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ development:
test:
mailer:
delivery_method: :test
intercept_and_forward_emails_to:
- john@example.com
- adam@example.com

staging:
mailer:
Expand Down

0 comments on commit f9f905f

Please sign in to comment.