メール設定をYAMLファイルから読み込む
Typo 5.2 (MIT-LICENSE)
config/environment.rb
if RAILS_ENV != 'test' begin mail_settings = YAML.load(File.read("#{RAILS_ROOT}/config/mail.yml")) ActionMailer::Base.delivery_method = mail_settings['method'] ActionMailer::Base.server_settings = mail_settings['settings'] rescue # Fall back to using sendmail by default ActionMailer::Base.delivery_method = :sendmail end end
config/mail.yml
method: :smtp settings: :address: mail.example.com :port: 25 :domain: example.com # :authentication: :login # :user_name: bob # :password: bobsyouruncle