diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index cca06e6..8567da5 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -300,7 +300,9 @@ def capable_starttls? # true if the EHLO response contains +key+. def capable?(key) return nil unless @capabilities - @capabilities[key] ? true : false + return true if @capabilities[key] + key = key.to_s + @capabilities.each_key.any? { |capability| capability&.casecmp?(key) } end # The server capabilities by EHLO response diff --git a/test/net/smtp/test_smtp.rb b/test/net/smtp/test_smtp.rb index 3b9e245..80d339d 100644 --- a/test/net/smtp/test_smtp.rb +++ b/test/net/smtp/test_smtp.rb @@ -51,6 +51,7 @@ def test_server_capabilities smtp = Net::SMTP.start('localhost', port, starttls: false) assert_equal({"STARTTLS"=>[], "AUTH"=>["PLAIN"]}, smtp.capabilities) assert_equal(true, smtp.capable?('STARTTLS')) + assert_equal(true, smtp.capable?('starttls')) assert_equal(false, smtp.capable?('DOES-NOT-EXIST')) else port = fake_server_start