title: Gmail smtp Hostname does not match the server certificate
body: <p>I'm having an error with <code>gmail</code> gem while trying to send a mail, this is working fine on local, and was working fine on heroku, but now im moving this app to a VPS server. This is the error:</p>
  
  <pre><code>e = g.compose do
     to 'test@gmail.com'
     subject 'testasea'
     body 'test'
  end
  
  =&gt; #&lt;Mail::Message:25450040, Multipart: false, Headers: &lt;From: .......&gt;
  e.deliver!
  =&gt; OpenSSL::SSL::SSLError: hostname does not match the server certificate
  </code></pre>
  
  <p>I've added this into an initializer file, without any luck:</p>
  
  <pre><code>ActionMailer::Base.smtp_settings = {
    :enable_starttls_auto =&gt; true,
    :openssl_verify_mode  =&gt; 'none' # I've tested with 0 and false,
  </code></pre>
  
  <p>}</p>
  
  <p>I tried to monkey path the class</p>
  
  <pre><code>OpenSSL::SSL::SSLSocket.class_eval do
   def post_connection_check(hostname)
     return true
   end
  end
  </code></pre>
  
  <p>with no luck, when I do that i receive a <code>535 Incorrect authentication data</code>, however I know data is ok because i can do</p>
  
  <pre><code>g.inbox.count :read
  </code></pre>
  
  <p>And it returns me the right number.</p>
  
  <p>I would like to know:</p>
  
  <ul>
  <li>the incorrect certificate is the one my server (smtp client) is sending? or the one that is received by gmail smtp server?</li>
  <li>why it works in local?</li>
  <li>Why if i monkey path the class I received an authentication error?</li>
  <li>Is there any workaround? i dont care if is not safe, is just a tenting application,.</li>
  </ul>