0
votes

I'm using foreman for the environment variables in a rails app. On my config/enviroments/development.rb I have the following code:

config.action_mailer.smtp_settings = { 
  address: "smtp.gmail.com",
  port: "587",
  domain: "gmail.com",
  authentication: "plain", 
  enable_starttls_auto: true,
  user_name: ENV['GMAIL_USERNAME'],
  password: ENV['GMAIL_PASSWORD'] 
  #user_name: "[email protected]",                    
  #password: "password"
}

and my .env file is as follows:

[email protected]
GMAIL_PASSWORD=password

and my Procfile is:

web: bundle exec rvmsudo rails s -p 80

So if I run "foreman start", I get the following message:

Net::SMTPAuthenticationError in Devise::ConfirmationsController#create 530-5.5.1 Authentication Required

However if I comment the lines that concern the environment variables and uncomment the ones that are commented right now at development.rb, everything works fine.

So I imagine the problem is that foreman is not getting the environment variables correctly. I'm using git with branches, and ignoring both Procfile and .env

Is there anything wrong with my code?

1

1 Answers

0
votes

Looks like the environment variables are not being set. Which method are you using to do that? Here's an article that explains several methods.

Try setting them manually on the command line thus:

export GMAIL_USERNAME="[email protected]"
export GMAIL_PASSWORD="password"

Then type env at the command prompt to verify they are set. Then give it a whirl.