Redmine email configuration with environment variables

一曲冷凌霜 提交于 2019-12-04 20:17:00

I had answered this question 2 weeks ago, and it was deleted by someone else right away. So I'm not sure if someone will delete this answer again to prevent other guys knowing how to solve this problem. Good luck!

I got the same issue and this article Set up mailing in redmine on heroku solved my problem.

The idea is moving the settings from config/configuration.yml to config/environments/production.rb and using Ruby code to set it up. Since ENV['key'] is handled by erb, I guess configuration.yml is not handled that way. Maybe there is some security issue?

So in your case, you should add these codes to config/environments/production.rb as follows,

ActionMailer::Base.smtp_settings = {
  :address        => 'smtp.sendgrid.net',
  :port           => '587',
  :authentication => :plain,
  :user_name      => ENV['SENDGRID_USERNAME'],
  :password       => ENV['SENDGRID_PASSWORD'],
  :domain         => 'heroku.com'
}
ActionMailer::Base.delivery_method = :smtp

And remove codes from config/configuration.yml and make it looks like this,

default:
  # Outgoing emails configuration (see examples above)
  email_delivery:
    delivery_method: :smtp
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!