2011-08-09 7 views
1

私はレールでメールを送信するための初心者です。私は自分のプロジェクトでデベロッパーを実装しましたが、現在、ウェルカムメールやパスワードリセットメールを送信したいと思います。 Deviseビューではどのような変更を行う必要がありますか? エラーは表示されませんが、まだメールは届きません。メールを送信するメールを添付する

私は下に指定されたリンクをたどってきたし、最終的に次のように私のdevise.rb、development.rbとproduction.rbファイルは、次のとおりです。

devise.rb 

config.mailer_sender = "[email protected]" 

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   => '[email protected]', 
:password   => '123456' 
} 

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   => '[email protected]', 
    :password   => '123456' 
} 
+0

可能重複にそのパラメータを設定します。 http://stackoverflow.com/questions/3794669/confirmation-email-from-devise-on-rails3-using-gmail-not-arriving –

+3

開発中のみテストしていますか?あなたは 'perform_deliveries'がfalseに設定されているからです。 –

+0

@ Andrei S:ねえ、ありがとう!!それが私の問題を解決しました! :-) – Rashmi

答えて

2

development環境でレールを使用して電子メールを送信しようとすると、あなたをdevelopmentの設定ファイルに、メールが実際に配信されるかどうかを指定する行config.action_mailer.perform_deliveries = falseがあることがわかります。

あなたはパラメータが自動的にfalseに設定されている新しいレールのプロジェクトを作成し、あなたが実際に開発モードで電子メールを送信したい場合、あなたは(他のものの間で)しなければならないtrue

関連する問題