Rails Devise发送邮件

Shr*_*uti 2 email ruby-on-rails send devise

我是通过铁路发送邮件的新手.我在项目实施的装置和后现在我想发送欢迎电子邮件和/或密码重置邮件.我需要在Devise视图中做出哪些更改?没有显示错误,但我仍然没有收到任何电子邮件.

我已经按照这些链接,最后我的devise.rb,development.rb和production.rb文件如下:

=== devise.rb ===

 config.mailer_sender = "xxx@gmail.com"
Run Code Online (Sandbox Code Playgroud)

=== development.rb ==

  config.action_mailer.raise_delivery_errors = false

  config.action_dispatch.best_standards_support = :builtin

  config.active_support.deprecation = :notify
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = false
  config.action_mailer.raise_delivery_errors = true

  config.action_mailer.default :charset => "utf-8"


  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.active_support.deprecation = :log

 config.action_mailer.smtp_settings ={
 :enable_starttls_auto => true,
 :address            => 'smtp.gmail.com',
 :port               => 587,
 :tls                => true,
 :domain             => 'gmail.com',
 :authentication     => :plain,
 :user_name          => 'xxx@gmail.com',
 :password           => 'xxxxxx' 
 }

 =====production.rb===
 config.action_mailer.default_url_options = { :host => 'gmail.com' }

  config.active_support.deprecation = :notify
   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"

  config.action_mailer.smtp_settings = {
  :enable_starttls_auto => true,
  :address            => 'smtp.gmail.com',
  :port               => 587,
  :tls                  => true,
  :domain             => 'gmail.com',
  :authentication     => :plain,
  :user_name          => 'xxx@gmail.com',
  :password           => 'xxxxxx' 
 }
Run Code Online (Sandbox Code Playgroud)

Aru*_*nan 10

尝试这样设置raise_delivery_errors = true:

config.action_mailer.perform_deliveries = true # Set it to false to disable the email in dev mode
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "localhost:3000" }


ActionMailer::Base.smtp_settings = {
                    :address        => "smtp.gmail.com",
                    :port           => 587,
                    :authentication => :plain,
                    :user_name      => "user@gmail.com",
                    :password       => "password"
}
Run Code Online (Sandbox Code Playgroud)