• RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

You guys may have stuck with following error while using ActionMailer with Rails 2.2.2 .

OpenSSL::SSL::SSLError (hostname was not match with the server certificate):
    /usr/lib/ruby/1.8/openssl/ssl.rb:123:in `post_connection_check'
    /usr/lib/ruby/1.8/net/smtp.rb:582:in `tlsconnect'
    /usr/lib/ruby/1.8/net/smtp.rb:562:in `do_start'
    /usr/lib/ruby/1.8/net/smtp.rb:525:in `start'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:671:in `perform_delivery_smtp'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:526:in `__send__'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:526:in `deliver!'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:392:in `method_missing'
    /app/controllers/users_controller.rb:40:in `send_email_to_confirm_user'

Actually, Rails 2.2.2 turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it.

If you use postfix, then you fix it quickly by disabling tls by setting “smtpd_use_tls=no” in /etc/postfix/main.cf .

Remember to restart postfix and rails app server.

10 Responses so far.

  1. km says:

    I have a VPS, that I am trying to get action mailer to work with. I don’t really want to turn off tls. Is there a way to get ruby to use tls without this error?

  2. Akhil Bansal says:

    I think the latest version of rails has an option to turn off tls for action mailer

  3. [...] to figure out what exactly was causing this problem I chanced across a post by Akhil Bansal at /2009/01/28/actionmailer-error-hostname-was-not-match-with-the-server-certifica…. He wrote: Actually, Rails 2.2.2 turn on STARTTLS if it is available in Net::SMTP (added in Ruby [...]

  4. Amit Solanki says:

    Thanks again for the quick info.

  5. rollo says:

    Thanks very much Sir!

  6. In the Rails 3 initializer, enter the following code to inform ActionMailer to “ignore” the OpenSSL error.

    ActionMailer::Base.smtp_settings = {
    :enable_starttls_auto => false
    }

  7. even better:
    :o penssl_verify_mode => ‘none’

    in the mailer settings for rails3 ..


Asset Pipeline has been extracted a...

The asset pipeline which was introduced in Rails 3.1, has ...

ClientSideValidations: Add/Map mode...

#/status/256699237230845952

Action and Page caching has been ex...

With the commit c82cf81f00f Action and Page caching has been extracted ...

turbo-sprockets-rails3: Speeds up ...

#/status/253420357841723393

EdgeRails: ActiveRecord::SessionSto...

With the commit 3324e28804 ActiveRecord::SessionStore is extracted out of Rails into ...

Asset Pipeline has been extracted a...

The asset pipeline which was introduced in Rails 3.1, has ...

ClientSideValidations: Add/Map mode...

#/status/256699237230845952

Action and Page caching has been ex...

With the commit c82cf81f00f Action and Page caching has been extracted ...

turbo-sprockets-rails3: Speeds up ...

#/status/253420357841723393

EdgeRails: ActiveRecord::SessionSto...

With the commit 3324e28804 ActiveRecord::SessionStore is extracted out of Rails into ...