2016-03-29 29 views
0

deviseを使用して、レール4の動的電子メールサーバーの設定でパスワードをリセットしようとしています。Errno :: ECONNREFUSED - 接続が拒否されました - "localhost"ポート25のconnect(2):

my_mailer.rb 

class MyMailer < Devise::Mailer 
    helper :application 
    include Devise::Controllers::UrlHelpers 
    default template_path: 'devise/mailer' 

    def reset_password_instructions(record, token, opts={}) 
     # Has been dynamically set in the mailer_set_url_options of application_controller.rb 
     # opts[:host] = Setup.email_url 
     opts[:address] = Setup.email_address 
     opts[:port] = Setup.email_port 
     opts[:domain] = Setup.email_domain 
     opts[:from] = Setup.email_username 
     super 
    end 
end 

しかし、同じエラーを取得して、問題になる可能性がありますどのようなすべてのヘルプは本当に参考になりますありがとうございました:) enter image description here

+0

は、私はちょうどそれに見ているスクリーンショットを追加ここ –

+0

@RajarshiDasをお使いのSMTP設定を投稿役立つかもしれない願っています。実際には何かが乱れてしまいました。 –

+0

あなたはhttp://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration-for-gmailのような環境smtp設定を投稿する必要があります –

答えて

1

まず第一に、私は、あなたが使用していると思うのスクリーンショット

あたりとしてプロバイダーとしてgmail

環境ファイル(development.rbまたはproduction.rb)にアクセスしてください。私はあなたが開発環境を使用していると思います。ファイルへ

ゴーconfig/environments/development.rb

config.action_mailer.default_url_options = { :host => "my.website.com" } 
config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
    address:    'smtp.gmail.com', 
    port:     587, 
    domain:    'website.com', 
    user_name:   '[email protected]', 
    password:    'password', 
    authentication:  'plain', 
    enable_starttls_auto: true 
} 

ThisDocを参照してください。

は、それはあなたが

+0

本当に申し訳なく思っていますが、それはそのように使用したくないという問題です。 : –

+0

動的なことはどういう意味ですか?あなたは任意のapiからサービスの設定を取得しています –

+0

私自身が設定を取得し、その設定自体を使用します。 –

関連する問題