Created
March 31, 2014 03:39
-
-
Save joshmcarthur/9884826 to your computer and use it in GitHub Desktop.
Load email settings from a YAML configuration file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/email.yml | |
--- | |
test: | |
:delivery_method: :test | |
:url_host: 'localhost:3000' | |
development: | |
:delivery_method: :smtp | |
:host: "localhost:1025" | |
production: | |
:delivery_method: :smtp | |
:address: 'localhost' | |
:port: 25 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/mail_settings.rb | |
email_settings = YAML.load_file("#{Rails.root.to_s}/config/email.yml")[Rails.env.to_s] | |
Rails.application.config.action_mailer.default_url_options = { | |
host: email_settings.delete(:url_host) || "localhost:3000" | |
} | |
Rails.application.config.action_mailer.delivery_method = email_settings.delete(:delivery_method) | |
Rails.application.config.action_mailer.smtp_settings = email_settings |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment