简体   繁体   English

Errno::ECONNREFUSED - 连接被拒绝 - “localhost”端口 25 的 connect(2):

[英]Errno::ECONNREFUSED - Connection refused - connect(2) for “localhost” port 25:

I am trying to reset the password with dynamic email server settings in rails 4 using devise.我正在尝试使用设计在 rails 4 中使用动态电子邮件服务器设置重置密码。

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

But getting the same error, what can be the issue any help will be really helpful thank you :)但是遇到同样的错误,可能是什么问题,任何帮助都会非常有帮助,谢谢:) 在此处输入图片说明

First of all as per the screenshot首先根据截图

I think you are using gmail as a provider.我认为您正在使用gmail作为提供商。

Please go to enviroments file( development.rb or production.rb ).请转到环境文件( development.rbproduction.rb )。 I guess you are using development environment.我猜你正在使用开发环境。

Go to the file config/environments/development.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:            'user@website.com',
    password:             'password',
    authentication:       'plain',
    enable_starttls_auto: true
}

Please refer ThisDoc .请参考ThisDoc

hope it might help you希望它可以帮助你

I am not using Devise but had the same error when trying to Dynamically change the smtp_settings of my application mailer.我没有使用 Devise,但在尝试动态更改应用程序邮件程序的 smtp_settings 时遇到了同样的错误。 In my case the settings came from the database.在我的情况下,设置来自数据库。 The way I made it work is by using after_action callback of ActionMailer .我让它工作的方式是使用ActionMailer after_action回调。 And to merge the settings for the delivery method of my mail并合并我的邮件投递方式的设置

Here is an example:下面是一个例子:

after_action do
 self.delivery_method = SETTING_FROM_DB.delivery_method
 settings = {
   address: SETTING_FROM_DB.address,
   port: SETTING_FROM_DB.port
   # More setting if needed
   }
 self.mail.delivery_method.settings.merge! settings
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Errno :: ECONNREFUSED(连接被拒绝-“ localhost”端口587的connect(2))操作邮件 - Errno::ECONNREFUSED (Connection refused - connect(2) for “localhost” port 587) action mailer 连接被拒绝 - 使用DigitalOcean连接(2)“localhost”端口9200 - Connection refused - connect(2) for “localhost” port 9200 with DigitalOcean Errno :: ECONNREFUSED:无法建立连接,因为目标计算机实际上拒绝了它。 -连接(2) - Errno::ECONNREFUSED: No connection could be made because the target machine acti vely refused it. - connect(2) 法拉第:: ConnectionFailed,连接被拒绝 - 连接(2)为“localhost”端口9200错误Ruby on Rails - Faraday::ConnectionFailed, Connection refused - connect(2) for “localhost” port 9200 Error Ruby on Rails Rails 4.2:sidekiq无法连接到以工头开始的Redis(Errno :: ECONNREFUSED) - Rails 4.2 : sidekiq cannot connect to Redis (Errno::ECONNREFUSED) started with foreman PG 错误无法连接到服务器:连接被拒绝服务器是否在端口 5432 上运行? - PG Error could not connect to server: Connection refused Is the server running on port 5432? Heroku Rails 4无法连接到服务器:连接被拒绝 - Heroku Rails 4 could not connect to server: connection refused PG::ConnectionBad - 无法连接到服务器:连接被拒绝 - PG::ConnectionBad - could not connect to server: Connection refused 连接到上游时connect()失败(111:连接被拒绝) - connect() failed (111: Connection refused) while connecting to upstream 机械化获取“Errno :: ECONNRESET:通过对等方重置连接 - SSL_connect” - Mechanize getting “Errno::ECONNRESET: Connection reset by peer - SSL_connect”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM