我设计的电子邮件在开发中运行良好。
但是现在我已经推送到 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 应用程序,我只是想先用现有的 Heroku 设置测试它。
最佳答案
一切正常,您是否检查过 sendgrid 帐户是否已配置?
如果您使用的是 heroku,请转到 sendgrid 面板完成设置,只需访问应用程序配置文件和资源(这是默认设置)下您应该会看到 sendgrid 附加组件,单击它并确保您有一切设置。在这种情况下,它会要求您设置一个模板,但您可以“跳过”这个。
希望这对您有所帮助!
关于ruby-on-rails - 为什么我的 Heroku 应用程序不使用 Sendgrid 发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27402833/