【问题标题】:Rails Devise send mailRails 设计发送邮件
【发布时间】:2011-10-23 00:32:37
【问题描述】:

我是通过 Rails 发送邮件的新手。我已经在我的项目中实现了设计,现在我想发送一封欢迎电子邮件和/或一封密码重置电子邮件。我需要在设计视图中进行哪些更改? 没有显示任何错误,但我仍然没有收到任何电子邮件。

我已经关注了这些链接,最后我的 devise.rb、development.rb 和 production.rb 文件如下:

=== 设计.rb ===

 config.mailer_sender = "xxx@gmail.com"

===发展.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' 
 }

【问题讨论】:

    标签: ruby-on-rails email devise send


    【解决方案1】:

    尝试像这样设置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"
    }
    

    【讨论】:

    • thnx...我意识到我必须将“perform_deliveries”设置为 true..它在没有 gem tlsmail 的情况下工作..
    【解决方案2】:

    您是否安装了“tlsmail”gem?

    点击链接在 rails 中使用 gmail 发送邮件

    http://ionrails.com/2009/07/27/sending-mail-via-gmail-with-rails-actionmailer/

    【讨论】:

      猜你喜欢
      • 2011-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-14
      相关资源
      最近更新 更多