OpenSSL certificate error in sending email using gmail smtp

Hello,

I’m getting this error in email deliver -

OpenSSL::SSL::SSLError: hostname does not match the server certificate

from /usr/local/lib/ruby/1.9.1/openssl/ssl-internal.rb:129:in `post_connection_check’

from /usr/local/lib/ruby/1.9.1/net/smtp.rb:585:in `tlsconnect’

from /usr/local/lib/ruby/1.9.1/net/smtp.rb:560:in `do_start’

from /usr/local/lib/ruby/1.9.1/net/smtp.rb:519:in `start’

from /home/deployer/bundle/ruby/1.9.1/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!’

from /home/deployer/bundle/ruby/1.9.1/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery’

from /home/deployer/bundle/ruby/1.9.1/gems/mail-2.5.4/lib/mail/message.rb:232:in `block in deliver’

from /home/deployer/bundle/ruby/1.9.1/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:456:in `block in deliver_mail’

from /home/deployer/bundle/ruby/1.9.1/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in `block in instrument’

from /home/deployer/bundle/ruby/1.9.1/gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument’

from /home/deployer/bundle/ruby/1.9.1/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in `instrument’

from /home/deployer/bundle/ruby/1.9.1/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:454:in `deliver_mail’

from /home/deployer/bundle/ruby/1.9.1/gems/mail-2.5.4/lib/mail/message.rb:232:in `deliver’

from (irb):13

from /home/deployer/bundle/ruby/1.9.1/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in `start’

from /home/deployer/bundle/ruby/1.9.1/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in `start’

from /home/deployer/bundle/ruby/1.9.1/gems/railties-4.0.2/lib/rails/commands.rb:62:in `<top (required)>’

from script/rails:6:in `require’

I’m on CentOS 6.5 using Ruby 1.9, Rails 4.0. I have upgraded to Ruby 2.0 but the error persists. openssl version is this: “OpenSSL 1.0.1e-fips 11 Feb 2013”

Anyone had a similar problem before?

Many thanks,

Abhishek