Rails Mailer Error" Errno :: ECONNREFUSED(连接被拒绝......)"安装后&卸载后缀

时间:2016-08-19 03:14:51

标签: ruby-on-rails actionmailer vps postfix-mta

我在Ruby on Rails上的应用程序突然出现错误,如下所示,当它尝试使用Gmail发送带有Mailer的电子邮件时。

此问题在我安装&卸载" postfix"在服务器(Apache / CentOS)上,因为安装对我来说太难了。在此之前,梅勒正常工作。

日志/ production.log

NoticeMailer#newtask_email: processed outbound mail in 2.5ms
I, [2016-08-19T10:55:13.429666 #3782]  INFO -- : 
Sent mail to email@example.com (4.2ms)
D, [2016-08-19T10:55:13.429750 #3782] DEBUG -- : Date: Fri, 19 Aug 2016 10:55:13 +0900
From: info@domain.com
To: email@example.com
Message-ID: <defaultdomain.mail>
Subject: test
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit  
(Message)
test

I, [2016-08-19T10:55:13.430023 #3782]  INFO -- : Completed 500 Internal Server Error in 17ms (ActiveRecord: 2.0ms)
F, [2016-08-19T10:55:13.431110 #3782] FATAL -- : 
Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):
app/controllers/tasks_controller.rb:41:in `create'

相关编码如下所示:

配置/环境/ development.rb

  config.action_mailer.default_url_options = { host: 'localhost:3000' }
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: 'smtp.gmail.com',
    port: 587,
    domain: 'gmail.com',
    authentication: :plain,
    user_name: 'xxxxx@gmail.com',
    password: 'xxxxx'
  }

编码应该没问题。所以,我想由于安装了后缀,一些服务器设置已经改变。

我按照网站上写的程序安装了postfix: http://tipszone.jp/20120521_mail_server/

并且,我通过&#34; yum erase postfix&#34;,&#34; yum remove dovecot&#34;,&#34; rm -rf / etc / postfix&#34;和&#34; rm -rf / etc / dovecot&#34;。之后我做了#34;重启&#34;和#34;服务httpd restart&#34;。

&#34;在/ etc / SYSCONFIG / iptables的&#34;和以前一样。

我不知道如何解决这个问题,所以请你帮帮我...

1 个答案:

答案 0 :(得分:0)

通过在production.rb上将相同的“config.action_mailer.smtp_settings”编码写为environment.rb,解决了这个问题。

在我安装postfix之前,因为默认设置而没有在production.rb上进行编码似乎很好。