title: ActionMailer SMTP "certificate verify failed"
body: <p>I want to send emails from my Rails web application, and I do not want to disable TLS certificate verification. However for some reason, it always fails with "SSLv3 read server certificate B: certificate verify failed", even though the server certificate is valid.</p>
  
  <p>I doubled checked with <code>openssl s_client</code> (using <code>/etc/ssl/certs/ca-certificates.crt</code>), and running the following in the rails console also works, delivering successfully.</p>
  
  <pre><code>smtp = Net::SMTP.new(host, port)
  smtp.enable_tls
  smtp.start("localhost", username, password, :login) do |smtp|
    smtp.send_message msgstr, from, to
  end
  </code></pre>
  
  <p>The server has Rails 4.2.6 and Ruby 2.3.0</p>
  
  <pre><code>config.action_mailer.smtp_setting = {
      address: 
      port: 465,
      user_name: 
      password: 
      authentication: :login,
      openssl_verify_mode: OpenSSL::SSL::VERIFY_PEER,
      enable_starttls_auto: false,
      ssl: true
  }
  </code></pre>