在Heroku上设置Devise和Sendgrid

ubi*_*que 22 devise sendgrid ruby-on-rails-3

我的网站托管在Heroku上,我安装了Sendgrid附加组件,因为它看起来好得令人难以置信 - 但到目前为止,没有任何电子邮件功能正常工作.我已经阅读了文档,它清楚地说只是添加 - 添加 - 是否需要更多配置才能让Devise工作?

当我选择"给我发新密码"时,我会得到一个404页面,这让我觉得还有更多.就像Sendgrid如何知道/在哪里使用预安装的Devise模板一样?

谢谢.

Luc*_*cas 52

我今天早上刚刚设置了Devise和SendGrid,没有任何问题.我要恢复我采取的步骤.

首先,安装Devise和SendGrid.恭喜你,你已经做到了;)

然后,为了生产,将其添加到您的文件中:

config/initializers/devise.rb :

config.mailer_sender = "mail-to-send@from.com"
Run Code Online (Sandbox Code Playgroud)

设置Rails ActionMailer以使用SendGrid

config/environments/production.rb
config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
ActionMailer::Base.smtp_settings = {
  :user_name            => ENV['SENDGRID_USERNAME'],
  :password             => ENV['SENDGRID_PASSWORD'],
  :address              => "smtp.sendgrid.net",
  :port                 => 587,
  :enable_starttls_auto => true,
  :authentication       => :plain,
  :domain               => "yourdomain.com"
}
Run Code Online (Sandbox Code Playgroud)

一切都很好用.注册确认,密码恢复......

此外,您应该使用Logging Expanded(它是免费的!)并使用heroku logs --tail(实时)检查您的日志.如果仍然出现错误,请发布日志.

祝你有美好的一天 !