Devise Mail is not being catched in development environment

时间:2016-04-07 10:38:51

标签: ruby-on-rails ruby devise

I have tried doing authentication using devise in my rails app, I have made use of the 'confirmable' module in devise. However I am able to sign up but i am not seeing any email captured on my mailcatcher user interface. How do I get this problem sorted???

My development.rb is configured as follows

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default_url_options = { :host  => 'localhost: 3000' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {:address => 'localhost', :port => 1025}


  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end

2 个答案:

答案 0 :(得分:-1)

您可以将Google Mail用作smtp服务器。

替换

config.action_mailer.smtp_settings = {:address => 'localhost', :port => 1025}

使用

ActionMailer::Base.smtp_settings = {
  :address        => 'smtp.gmail.com',
  :domain         => 'mail.google.com',
  :port           => 587,
  :user_name      => 'your@gmail.com',
  :password       => 'password',
  :authentication => :plain,
  :enable_starttls_auto => true
}

答案 1 :(得分:-1)

对我来说,我使用了以下配置

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    :address              => "smtp.gmail.com",
    :port                 => 587,
    :user_name            => "your_gmail",
    :password             => "your_password",
    :authentication       => "plain",
    :enable_starttls_auto => true
}

然后我打开了我的电子邮件并打开了这个https://www.google.com/settings/security/lesssecureapps,然后将其设置为开启。

请记住在编辑development.rb后重启服务器