Skip to content

Net::SMTP behaves differently in JRuby than in MRI #204

Description

@ylansegal

Sometime after jruby-1.7.19 a change was introduced that changes the Net::SMTP behavior with respect with MRI.

Repro:

require "net/smtp"

message = <<-END_OF_MESSAGE
From: Your Name <your@mail.address>
To: Destination Address <someone@example.com>
Subject: test message
Date: Sat, 23 Jun 2001 16:26:43 +0900
Message-Id: <unique.message.id.string@example.com>

This is a test message.
END_OF_MESSAGE

smtp = Net::SMTP.new("smtp.somewhere.com", 25)

# This is weird, since we are not using TLS but done by default in the "mail" gem
# In any case, in MRI it doesn't cause any issue.
smtp.enable_starttls_auto

smtp.start("localhost") do |smtp_obj|
 response = smtp_obj.send_message(message, "sender@somewhere.com", "receiver@somewhere.com")
end

In jruby-1.7.22 and jruby-9.0.1.0 I get a Java stack-trace:

$ ruby repro.rb
Handshaker.java:1429:in `checkThrown': java.lang.RuntimeException: Algorithm NONE not available
    from SSLEngineImpl.java:535:in `checkTaskThrown'
    from SSLEngineImpl.java:813:in `readNetRecord'
    from SSLEngineImpl.java:781:in `unwrap'
    from SSLEngine.java:624:in `unwrap'
    from SSLSocket.java:605:in `readAndUnwrap'
    from SSLSocket.java:483:in `doHandshake'
    from SSLSocket.java:233:in `connectImpl'
    from SSLSocket.java:210:in `connect'

I can confirm that in jruby-1.7.19 and MRI (2.2.3) the mail message is sent as expected.

I think it's a little weird that the mail gem call enable_starttls_auto by default, unless explicitly told not to (https://github.com/mikel/mail/blob/master/lib/mail/network/delivery_methods/smtp.rb), but in any case, I believe the difference in behavior of the current JRuby release and MRI is worth addressing.

Please do let me know if more information is needed.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions