【发布时间】:2018-10-22 15:02:14
【问题描述】:
我正在尝试使用我的 Rails 应用程序中的 SendGrid 发送邮件(使用 Hartl 的教程)。仅仅使用 Heroku 的插件是行不通的,因为它需要我的信用卡。然后我在 SendGrid 上注册并使用我的凭据,但仍然没有邮件。上面是我的 production.rb 文件。请帮忙?
config.action_mailer.delivery_method = :smtp
host = '<https://nameless-sierra-13544>.herokuapp.com'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['myusername'],
:password => ENV['mypass#'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
谢谢,
【问题讨论】:
-
您的
host值是否包含<和>?为什么:domain设置为'heroku.com'?那不应该是您应用的完整域吗? -
你解决过这个问题吗?
-
@Rockwell Rice,实际上没有,我听从了你的建议,但没有奏效,也许问题出在代码的其他地方,我无法弄清楚。
-
你在 heroku 中设置了所有的 ENV 变量,对吗?
-
我一开始当然没有,现在它可以用于开发。我加密了我的 gmail 凭据(使用:rails credentials:edit)并且变量设置正确。
标签: ruby-on-rails heroku sendgrid