A bit late but I also encountered this error but with the Ruby Mail gem. If your SMTP server supports TLS, it will attempt to use TLS and authenticate the SSL certificate. If the certificate is issued for a hostname other than the one used or if the certificate cannot be authenticated (for example if it's self-signed and you don't trust the CA), then it will fail with the error "hostname does not match the server certificate".
To get around it, use the :openssl_verify_mode option. This can be set to OpenSSL::SSL::VERIFY_NONE to do no verification of the certificate - it will still encrypt the SMTP session though. Or there are other options available within the OpenSSL library.
Using your example, it would be:
Pony.mail({
:to => email_address,
:from => 'MyChairSales <support@mychairsales.com>',
:subject => subject,
:body => email_body,
:html_body => html_body,
:via => :smtp,
:via_options => {
:openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE,
:address => 'mail.mychairsales.com',
:port => '25',
:enable_starttls_auto => true,
:user_name => 'mychairs',
:password => 'thepassword',
:domain => "mychairsales.com" # the HELO domain provided by the client to the server
}
})
This also works for the Mail gem as well.