Rails: Can't get mailer to work when I set credentials as environment variables -


i setting contact form in rails 4 app, send emails using gmail. first, got work these settings in config/environments/development.rb:

config.action_mailer.delivery_method = :smtp config.action_mailer.raise_delivery_errors = true config.action_mailer.smtp_settings = {   address:              'smtp.gmail.com',   port:                 587,   domain:               'gmail.com',   user_name:            'myusername@gmail.com',   password:             'mypassword',   authentication:       'plain',   enable_starttls_auto: true } 

then used this approach setting environment variables in config/environment_variables.yml , loading config/initializers/environment_varibles.rb, , changed smtp settings in config/environments/development.rb to:

config.action_mailer.delivery_method = :smtp config.action_mailer.raise_delivery_errors = true config.action_mailer.smtp_settings = {   address:              'smtp.gmail.com',   port:                 587,   domain:               'gmail.com',   user_name:            env["gmail_username"],   password:             env["gmail_password"],   authentication:       'plain',   enable_starttls_auto: true } 

my config/environment_variables.yml file looks this:

development:   gmail_username: myusername@gmail.com   gmail_password: mypassword production:   gmail_username: myusername@gmail.com   gmail_password: mypassword 

now, mailer serves me error "net::smtpauthenticationerror". find strange environment variables seems loaded fine when start server. check in rails console:

2.3.0 :001 > env["gmail_username"]  => "myusername@gmail.com"  2.3.0 :002 > env["gmail_password"]  => "mypassword"  

i have switched , forth between working hard coded original solution , non-working environment variable solurion. have double checked spelling of credentials several times. have looked solution 2 days, , have feeling i'm missing simple.

does have clue of problem might be? :-)


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -