【发布时间】:2012-04-16 09:49:17
【问题描述】:
我在从我的 heroku 应用程序发送的电子邮件中包含链接。我遵循了 ActionMailer railscast 并且在开发中一切都运行良好,但是当使用 heroku/sendgrid 时,链接是在没有主机的情况下发送的。例如,链接不是http://www.reelify.com/users/2,而是http://users/2
这是我在初始化程序中的 setup_mail.rb:
require 'development_mail_interceptor'
if Rails.env.production?
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => 'XXX',
:password => 'XXX',
:domain => 'heroku.com'
}
else
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "reelify.com",
:user_name => "XXX",
:password => "XXX",
:authentication => "plain",
:enable_starttls_auto => true
}
end
ActionMailer::Base.default_url_options[:host] = "reelify.com"
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
我也尝试将此行添加到我的 production.rb 但现在在我测试时它被注释掉了:
config.action_mailer.default_url_options = { :host => 'reelify.com' }
有人有什么想法吗?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3.1 heroku actionmailer