Skip to content

Setting ENV Variables in Rails

richlewis14 edited this page Nov 4, 2012 · 2 revisions

To keep passwords and usernames protected/hidden from public view, in this case within the smtp settings for sending emails via devise

To set the credentials we do this from the command line

 export USER_NAME=example
 export PASSWORD=example

Then in our mailer settings we can call the password like so

   ActionMailer::Base.smtp_settings = {
   :address              => "smtp.gmail.com",
   :port                 => 587,
   :domain               => 'gmail.com',
   :user_name            => '[email protected]',
   :password             => ENV["PASSWORD"],
   :authentication       => 'plain',
   :enable_starttls_auto => true  }
   end