我的设计电子邮件在开发中效果很好。

但是,既然我已经推送到Heroku并正在使用sendgrid附加组件,则不会发送它们。我没有错。好像发送的很好,只是它从未真正到达我的收件箱。

这是我的config/environment/production.rb文件:

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
config.action_mailer.default_url_options = { :host => 'http://myapp.herokuapp.com' }

config.action_mailer.smtp_settings = {
  :user_name => ENV["SENDGRID_USERNAME"],
  :password => ENV["SENDGRID_PASSWORD"],
  :address => 'smtp.sendgrid.net',
  :domain => 'myapp.herokuapp.com',
  :port => 587,
  :authentication => :plain,
  :enable_starttls_auto => true
}


我在Heroku上检查了这些配置变量,它们返回有效结果。

有任何想法吗?

附言我还没有指向Heroku App的域,我只想先使用现有的Heroku设置对其进行测试。

最佳答案

一切看起来不错,您是否检查了sendgrid帐户是否已配置?

如果您在heroku上,请转到sendgrid面板以完成设置,只需访问应用程序配置文件,然后在资源(这是默认设置)下,您应该会看到sendgrid加载项,单击它并确保已完成所有设置。在这种情况下,它将要求您设置模板,但是您可以“跳过”此模板。

希望这可以帮助!

09-17 21:03
查看更多