title: Connection refused - connect(2) for "localhost" port 25 rails
body: <p>During my training, I'm working on a website and we use Ruby on Rails. We need to send mails to users so I created a mailer.</p>
  
  <p>I have tried to put the smtp in both <code>development.rb</code> and <code>environment.rb</code></p>
  
  <pre><code>config.action_mailer.default_url_options = {host: '0.0.0.0:3000'}
  config.action_mailer.default charset: 'utf-8'
  config.action_mailer.delivery_method = 'smtp'
  config.action_mailer.perform_deliveries = true
  config.action_mailer.smtp_settings = {
    adress: $SMTP_SERVER,
    port: $PORT,
    from: $MAIL,
  
    enable_starttls_auto: true
    #authentication: 'login'
  }
  </code></pre>
  
  <p>It tells me that the error comes from this method line 6  </p>
  
  <pre><code>def create
    @user = User.new(user_params)
  
    respond_to do |format|
      if @user.save
        # Tell the UserMailer to send a welcome Email after save
        UserMailer.welcome_email(@user).deliver_now
  
        format.html { redirect_to(@user, :notice =&gt; 'User was successfully created.') }
        format.json { render :json =&gt; @user, :status =&gt; :created, :location =&gt; @user }
      else
        format.html { render :action =&gt; "new" }
        format.json { render :json =&gt; @user.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end
  </code></pre>
  
  <p>I have set the port to <code>587</code> but i keep getting the error:</p>
  
  <blockquote>
    <p>Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost"
    port 25</p>
  </blockquote>
  
  <p>It looks as if another file was overwriting my settings. I also saw that it might be related to my ssh key not being authorized by the server.   </p>
  
  <p>Do know what is wrong?  </p>
  
  <p>Thanks in advance</p>