Skip to content

Commit

Permalink
Enable TLS support under Ruby 1.8.x.
Browse files Browse the repository at this point in the history
There needs to be a check for which version of ruby is being used
when trying to enable tls support.   Ruby 1.8 Net::SMTP does not
support the context object for enabling the TLS support, you
need to pass the OPEN::SSL::VERIFY related constant directly.

This patch checks for the version of Ruby and enables it as appropriate.
  • Loading branch information
kingargyle committed Feb 23, 2012
1 parent 47e288e commit 9890b19
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/mail/network/delivery_methods/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,13 @@ def deliver!(mail)
if openssl_verify_mode.kind_of?(String)
openssl_verify_mode = "OpenSSL::SSL::VERIFY_#{openssl_verify_mode.upcase}".constantize
end
context = Net::SMTP.default_ssl_context
context.verify_mode = openssl_verify_mode
smtp.enable_starttls_auto(context)
if RUBY_VERSION >= '1.9.0'
context = Net::SMTP.default_ssl_context
context.verify_mode = openssl_verify_mode
smtp.enable_tls(context)
else
smtp.enable_tls(openssl_verify_mode)
end
end
end
end
Expand Down

0 comments on commit 9890b19

Please sign in to comment.