【发布时间】: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