Reputation: 3654
I'm creating simple form to email form using actionmailer in a Rails 4 app.
When I use the following settings in my development.rb file everything works fine:
config.action_mailer.default :charset => "utf-8"
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "mail.hover.com",
port: 587,
domain: "blah.com",
user_name: "[email protected]",
password: "thisBeMyPassword",
authentication: 'plain',
enable_starttls_auto: true,
openssl_verify_mode: 'none'
}
But when I try to use a an ENV variable in my code like so, I get an authentication fails error:
config.action_mailer.default :charset => "utf-8"
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "mail.hover.com",
port: 587,
domain: "blah.com",
user_name: "[email protected]",
password: ENV["MY_EMAIL_PASSWORD"],
authentication: 'plain',
enable_starttls_auto: true,
openssl_verify_mode: 'none'
}
I can see this variable in the terminal when I use printenv
in the console and when I stick puts ENV["MY_EMAIL_PASSWORD"]
in the code.
I've triple-checked spelling, capitalization, etc.
Upvotes: 0
Views: 1090
Reputation: 459
I can't see the problem but I can recommend the figaro gem. It makes it really easy to handle environment variables. Give it a try and let me know.
Upvotes: 1