设计不发送邮件

时间:2011-04-26 17:04:55

标签: ruby-on-rails email devise actionmailer

我在config / environments / development.rb中有以下内容:

config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :enable_starttls_auto => true,
    :address => "smtp.gmail.com",
    :port => 587,
    :domain => "mydomain.com",
    :authentication => :login,
    :user_name => "myemaiL@mydomain.com",
    :password => "mypass"
  }

但是,当我浏览localhost:3000 / users / sign_in并尝试运行忘记密码(测试邮件发送)时,我收到此错误:

RuntimeError in Devise/passwords#create

Showing /Users/TTS/.rvm/gems/ruby-1.9.2-p180/gems/devise-1.3.3/app/views/devise/mailer/reset_password_instructions.html.erb where line #5 raised:

Missing host to link to! Please provide :host parameter or set default_url_options[:host]

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

看起来您需要为您的环境提供default_url。尝试将类似config.action_mailer.default_url_options = { :host => 'localhost:3000' }的内容添加到您的development.rb文件中(假设这是用于开发)