Make the mailer respect APP_CONFIG.host, add ENV switches for letter_opener, mailcatcher and sendmail

This commit is contained in:
Yuki 2015-07-21 23:03:30 +05:30
parent 7af0b73174
commit e76871b75f
3 changed files with 11 additions and 4 deletions

View File

@ -16,8 +16,15 @@ Rails.application.configure do
# Action Mailer Setup
# if you want to test sending mails locally, uncomment the line below and comment the :sendmail line
# config.action_mailer.delivery_method = :letter_opener
config.action_mailer.delivery_method = :sendmail
config.action_mailer.default_url_options = { host: 'justask.local' }
if ENV["mailcatcher"] == "yes"
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
elsif ENV["letteropener"] == "yes"
config.action_mailer.delivery_method = :letter_opener
else
config.action_mailer.delivery_method = :sendmail
end
config.action_mailer.perform_deliveries = true
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

View File

@ -68,7 +68,7 @@ Rails.application.configure do
config.active_support.deprecation = :notify
config.action_mailer.delivery_method = :sendmail
config.action_mailer.default_url_options = { host: 'retrospring.net' }
# config.action_mailer.default_url_options = { host: 'retrospring.net' }
config.action_mailer.perform_deliveries = true
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.

View File

@ -1,2 +1,2 @@
APP_CONFIG = YAML.load_file(Rails.root.join('config', 'justask.yml'))
Rails.application.config.action_mailer.default_url_options = { host: APP_CONFIG['hostname'] }