Skip to content

Instantly share code, notes, and snippets.

@geekdreamzz
Created September 12, 2013 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekdreamzz/6533103 to your computer and use it in GitHub Desktop.
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…
#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:
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