1

This is probably a easy question but cant seem to find a straight answer. I'm trying to set up a mailer and config the smtp settings and I was wondering how do you set new environment variables for

:user_name      => ENV['GMAIL_USERNAME'],
:password       => ENV['GMAIL_PASSWORD']

Thanks for the help.

1
  • are you trying to set environment variabel for heroku ? Commented Jul 19, 2017 at 3:17

3 Answers 3

1

You can set them up and keep them secret using the Figaro Gem

Add it to your Gemfile and bundle. Then install Figaro:

bundle exec figaro install

Once it's installed, you'll have a new file called application.yml in your config folder

You can create environment variables there and they're ignored by Git so your secrets won't get published.

You can set different variables for different environments if you want.

development:
  GMAIL_USERNAME: '[email protected]'
  GMAIL_PASSWORD: notaRE41p4ssw0rD

production:
  GMAIL_USERNAME: '[email protected]'
  GMAIL_PASSWORD: notaRE41p4ssw0rD317h3R

To push them to Heroku:

$ figaro heroku:set -e production
Sign up to request clarification or add additional context in comments.

Comments

1

Have a look at the dotenv gem as well. Figaro seems to be poorly maintained at the moment.

Comments

0

Another option beside accepted answer, for heroku setting environment variabel can be setup using heroku terminal command as follow

heroku config:set GMAIL_USERNAME=******* 
heroku config:set GMAIL_PASSWORD=******

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.