我为heroku部署了一个rails 5 app。我使用mailgun发送电子邮件,它在开发中运行良好。在我尝试注册用户的生产中,我收到此错误:
production.rb:
config.action_mailer.delivery_method = :mailgun
config.action_mailer.default_url_options = { :host => 'http://myappname.herokuapp.com', :protocol => 'https'}
config.action_mailer.mailgun_settings = {
domain: ENV['MAILGUN_DOMAIN'],
api_key: ENV['MAILGUN_KEY']
}
MAILGUN_DOMAIN和MAILGUN_KEY作为环境变量存储在我的PC中。有什么我做不对的吗?谢谢!
安装figaro gem之后:
application.yml
development:
MAILGUN_DOMAIN: ******************************
MAILGUN_KEY: **************************
production:
MAILGUN_DOMAIN: ******************************
MAILGUN_KEY: **************************
I still get the same error!!
看起来它与根据this issue on mailgunner安装的邮件gem的版本有关。
解决方法建议明确将mail gem添加到Gemfile并将版本锁定到2.6.5。
gem 'mail', '2.6.5'
然后,您需要运行bundle update mail --conservative
才能获得新版本。