Rails Devise отправлять почту - PullRequest
       25

Rails Devise отправлять почту

2 голосов
/ 09 августа 2011

Я новичок в отправке почты через рельсы. Я внедрил устройство в своем проекте, и теперь я хочу отправить приветственное письмо и / или письмо для сброса пароля. Какие изменения мне нужно сделать в представлении Devise? Ошибки не отображаются, но я по-прежнему не получаю письма.

Я перешел по этим ссылкам и, наконец, мои файлы devise.rb, development.rb и production.rb выглядят следующим образом:

=== devise.rb ===

 config.mailer_sender = "xxx@gmail.com"

=== 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' 
 }

Ответы [ 2 ]

10 голосов
/ 09 августа 2011

Попробуйте установить 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"
}
1 голос
/ 09 августа 2011

Вы установили гем 'tlsmail'?

Перейдите по ссылке для отправки почты с помощью gmail в rails

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

...