Created
September 12, 2013 04:36
-
-
Save geekdreamzz/6533103 to your computer and use it in GitHub Desktop.
Have you ever needed to set different SMTP settings for Action Mailer in your different environments? Perhaps yes perhaps no, but here's an easy to implement solution. Do you agree with this solution? 1. add mailer_settings.rb to the /initializers directory in your Rails app
2. edit the email_settings.yml with your specific SMTP settings and sav…
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
#Action Mailer SMTP settings | |
#Visit http://guides.rubyonrails.org/configuring.html#configuring-action-mailer | |
#For all possible configurations | |
development: | |
:address: | |
:port: | |
:authentication: | |
:user_name: | |
:password: | |
:enable_starttls_auto: | |
production: | |
:address: | |
:port: | |
:authentication: | |
:user_name: | |
:password: | |
:enable_starttls_auto: |
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
if Rails.env != 'test' | |
email_settings = YAML::load(File.open("#{Rails.root.to_s}/config/email_settings.yml")) | |
ActionMailer::Base.smtp_settings = email_settings[Rails.env] unless email_settings[Rails.env].nil? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment