Chore: Configure Letter opener with environment variable (#880)

This commit is contained in:
Sojan Jose
2020-05-20 20:02:28 +05:30
committed by GitHub
parent 8af200ad20
commit f6a9f791cf
2 changed files with 13 additions and 10 deletions

View File

@@ -105,3 +105,7 @@ CHARGEBEE_WEBHOOK_PASSWORD=
## Bot Customizations
USE_INBOX_AVATAR_FOR_BOT=true
## Development Only Config
# if you want to use letter_opener for local emails
# LETTER_OPENER=true

View File

@@ -34,18 +34,12 @@ Rails.application.configure do
config.active_job.queue_adapter = :sidekiq
# Email related config
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { host: 'localhost:3000' }
config.action_mailer.default_url_options = { host: ENV['FRONTEND_URL'] }
# If you want to use letter opener instead of mailhog for testing emails locally,
# uncomment the following line L49 and comment lines L51 through to L65
# config.action_mailer.delivery_method = :letter_opener
config.action_mailer.delivery_method = :smtp
smtp_settings = {
port: ENV['SMTP_PORT'] || 25,
domain: ENV['SMTP_DOMAIN'] || 'localhost',
@@ -59,7 +53,12 @@ Rails.application.configure do
smtp_settings[:enable_starttls_auto] = ENV['SMTP_ENABLE_STARTTLS_AUTO'] if ENV['SMTP_ENABLE_STARTTLS_AUTO'].present?
end
config.action_mailer.smtp_settings = smtp_settings
if ENV['LETTER_OPENER']
config.action_mailer.delivery_method = :letter_opener
else
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = smtp_settings
end
# Set this to appropriate ingress service for which the options are :
# :relay for Exim, Postfix, Qmail
@@ -69,7 +68,7 @@ Rails.application.configure do
# :sendgrid for Sendgrid
config.action_mailbox.ingress = ENV.fetch('RAILS_INBOUND_EMAIL_SERVICE', 'relay').to_sym
Rails.application.routes.default_url_options = { host: 'localhost', port: 3000 }
Rails.application.routes.default_url_options = { host: ENV['FRONTEND_URL'] }
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log