Rails Mailer Error "Errno::ECONNREFUSED (Connection refused...)" After Installed & Uninstalled Postfix
<p>My app on Ruby on Rails has suddenly got an error, shown as below, when it tries to send an email with a Mailer using Gmail.</p>

<p>This problem started after I installed &amp; uninstalled "postfix" on the server (Apache/CentOS) since the installation was too difficult for me. Before that, the Mailer was properly working. </p>

<p><em>log/production.log</em></p>

<pre><code>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: &lt;defaultdomain.mail&gt;
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'
</code></pre>

<p>Related coding is shown as below:</p>

<p><em>config/environments/development.rb</em></p>

<pre><code>  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'
  }
</code></pre>

<p>The coding on should be fine. So, I guess some server settings have been changed due to the installation of postfix.</p>

<p>I installed postfix following the procedure written on the webiste:
<a href="http://tipszone.jp/20120521_mail_server/" rel="nofollow">http://tipszone.jp/20120521_mail_server/</a></p>

<p>And, I uninstalled it by "yum erase postfix", "yum remove dovecot", "rm -rf /etc/postfix" and "rm -rf /etc/dovecot". After that I did "reboot" and "service httpd restart".</p>

<p>"/etc/sysconfig/iptables" is also same as before.</p>

<p>I have no idea about how to fix this, so could you help me out please...</p>