【问题标题】:Sending mail for devise为设计发送邮件
【发布时间】:2017-01-19 00:41:24
【问题描述】:

我正在尝试通过我的 rails 应用程序中的 sendgrid 发送邮件。我之前已经设置了 sendgrid。通过heroku,我能够在开发和生产中发送和接收邮件。一切都工作了一天。几天后我回来了,但没有任何效果。

没有错误。在开发中,它说邮件已发送,但电子邮件未发送,生产环境也一样。

这是我的设置:

development.rb

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

production.rb

config.action_mailer.default_url_options = { host: 'herokuapp.com' }
Rails.application.routes.default_url_options[:host] = 'herokuapp.com' 
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"

setup_mail.rb

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
    address:                'smtp.sendgrid.net',
    port:                   '587',
    :authentication         => :plain,
    user_name:              'user',
    password:               'pass',
    domain:                 'herokuapp.com',
    enable_starttls_auto: true
}

我尝试将我的通行证重置为 sendgrid 并删除然后重新添加它,但是我遇到了一个错误,说“用户被禁止”并且我无法重新添加它。

我也尝试过切换到邮戳,结果类似,邮件从未收到但已发送。

【问题讨论】:

  • 在您的production.rb 中,尝试将您的主机值从herokuapp.com 更改为您的实际heroku url,例如safe-sample-1234.herokuapp.com
  • @jeramaedybohol 我这样做了,但结果相同

标签: ruby-on-rails heroku devise sendgrid


【解决方案1】:

您应该检查 Sendgrid 是否收到您的电子邮件请求。

来自documentation

在电子邮件活动中搜索电子邮件。如果我们成功传递了消息,您将看到一个带传递时间的传递事件。如果您没有看到电子邮件出现,您可以单击搜索选项并确保选中已处理和延迟。已处理的事件表明我们确实收到了您的请求。延迟事件显示接收服务器接受消息时是否存在问题或延迟。

【讨论】:

猜你喜欢
  • 2011-10-23
  • 1970-01-01
  • 2016-08-11
  • 2011-10-23
  • 1970-01-01
  • 1970-01-01
  • 2016-08-04
  • 2011-12-28
  • 1970-01-01
相关资源
最近更新 更多